Java sdk version check

How to know what JDK IntelliJ IDEA is using

I have looked at: https://intellij-support.jetbrains.com/hc/en-us/articles/206827547-Selecting-the-JDK-version-the-IDE-will-run-under and https://intellij-support.jetbrains.com/hc/en-us/articles/206827537-Configuring-JVM-options-and-platform-properties How can I know what version and path of JDK my IntelliJ IDEA is using? I have tried setting the environment variable IDEA_JDK. But I am not sure which version of JDK the IDE is picking up. is there a log I could see to verify this? System information

IntelliJ-IDEA 15 Windows 7, 64 bit 

3 Answers 3

Default locations

On the Mac, the default location is:

/Applications/IntelliJ IDEA .app/Contents/jdk/Contents/Home/jre 

On Windows, the default location is:

C:\Program Files\JetBrains\IntelliJ IDEA \jre64 

(Does anyone know what the default location is on linux?)

If these default locations do not work, here are two ways to find out the actual location:

Method #1

  • Go to Settings → Build, Execution, Deployment → Build Tools → Maven → Runner
  • Open the «JRE:» dropdown list
  • Select the «Use Internal JRE» entry.
  • Look at the path. (It will probably be abbreviated, so you will probably have to divine it.)

Method #2

  • Execute the «Find Action. » action. The default key binding for this action is Ctrl+Shift+A . This brings up a dialog where you can type the name of any action to find it and execute it.
  • In the dialog that opens, type «Switch» and from the suggested matches select «Switch Boot JDK. «. This will execute the «Switch Boot JDK. » action for you, which is not bound to any key by default and it cannot be found in any of the menus.
  • In the dialog that opens you can see the currently selected «Boot JDK». There is even a button to copy the path to your clipboard.

I find it amazing that IntelliJ IDEA does not seem to readily provide this information. Every time I install a new version of IntelliJ IDEA I have to go to the IntelliJ IDEA JRE and execute the keytool to install a certificate into this new JRE so that it can access the internal maven repositories that we use. So, every time this happens, I need to know where the internal JRE is. And I usually have to do it both for the mac at work and for windows at home, which is quite tedious.

Источник

How to know JDK version from within Java code

I presume you mean just the Java version, in which case try this:

String version = System.getProperty("java.version"); 

Relying on the java.version string for anything else than showing to a human is fragile and will break if running on another Java implementation.

The only reliable way programatically is to use reflection to carefully ask if a given facility is available, and then select the appropriate code accordingly.

@Jesse, I’d rather put it the other way around. What rule would you set up for analyzing the java.version string?

Читайте также:  Свойства фона изображения css

@Jesse, I was unaware of this property. I can, however, not see from a quick look in the JLS that it is guaranteed to be present and containing a valid number. Perhaps you know where it says so?

@Jesse, the crucial question here if this is for Hotspot-based JVM’s only. I cannot immediately tell.

Don’t use Float.valueOf like @JesseBarnum. This failed for me because 1.8>=1.8 returned false for me, due to round-off errors. Use .compareTo(«1.8»)>=0 instead.

System.out.println(Runtime.version()); 

Prints something like 17.0.2+8-86

System.out.println("Java Feature Version = " + Runtime.version().feature()); System.out.println("Java Interim Version = " + Runtime.version().interim()); System.out.println("Java Update Version = " + Runtime.version().update()); System.out.println("Java Version Build = " + Runtime.version().build().map(String::valueOf).orElse("Unknown")); System.out.println("Java Version Pre-Release Info = " + Runtime.version().pre().orElse("N/A")); 
Java Feature Version = 17 Java Interim Version = 0 Java Update Version = 2 Java Version Build = 8 Java Version Pre-Release Info = N/A 

Источник

How to know the jdk version on my machine?

First uninstall all the versions of Java, install Jdk 8. Open new command prompt and type java -version.

If your JDK is on your path you should be able to tell by just running ‘javac -version’. From the error you described it sounds like you’re on Windows, so if the first command fails try executing (with the quotes) the following: «%JAVA_HOME%\bin\javac -version»

@AlexBroadwin your method worked for me. But i’ve installed 8th version and in cmd «1.8.0_221» is coming. What does that mean?

4 Answers 4

you might need to add path in environment variables which you can find in Control Panel open the Jdk where you installed and add until /bin in the path in environment variables.

Add until /bin in path variable in System Variables which is residing in Environment Variables.

Then do java -version which might show up.

If still problem persists, try restarting your pc and see.

Your method worked for me. But i’ve installed jdk version 8 and in cmd java version «1.8.0_221» is coming. What does that mean?

you are good, you have installed Java 8 and the _221 is just the update release(They keep on adding some features or there will be minor updates), for more info you can refer by clicking here oracle.com/technetwork/java/javase/…

-version is useless: C:\Windows\system32>java -version java version «1.8.0_281» Java(TM) SE Runtime Environment (build 1.8.0_281-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

You need to update your Windows path to include your %JAVA_HOME%\bin directory. %JAVA_HOME% is the directory that you installed Java into and is also an environment variable that you need to configure for command line execution of your applications. You can edit both of these in the Windows control panel and you should restart.

When you run java -version you will see the internal version number. This is explained here: https://en.wikipedia.org/wiki/Java_version_history.

Basically, you can ignore the 1. when reading version number. The _xxx is a reference to the most recent patch or build release.

java version vs jdk versions could be different ? Seems useless or confusing at best ! JDK, JSE, it’s all a bit bloody mess

On Windows 10, this required mapping the environment variable for JAVA_HOME to the JDK installation directory. Use these steps:

Читайте также:  Https it tehnik ru software windows 10 disable serv win10 html

enter image description here

  1. Run the installer for the JDK. (available for windows here: https://www.oracle.com/java/technologies/downloads/#jdk17-windows)
  2. windows key -> Environment Variables , select the only result
  3. In the System Properties window that opened, select Environment Variables
  4. Select new button under the User variables section
  5. Variable name: JAVA_HOME , Variable Value:
  6. ok all open menus
  7. Close any open cmd prompt windows
  8. open a new cmd window and type echo %JAVA_HOME% It should print the installation path for the JDK.

To get your jdk location in Windows, run this at a command prompt:

This lists any and all locations of java.exe, including from your JAVA_HOME. For example, the 3rd line here reflects my JAVA_HOME location, where I’m pointing to JDK 8:

C:\Users\me> where java C:\Program Files\Common Files\Oracle\Java\javapath\java.exe C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe C:\Program Files\Java\jdk1.8.0_202\bin\java.exe 

Note for comparison that java -version does not reflect my JAVA_HOME location and in fact shows java version 11 instead of 8:

C:\Users\me> java -version java version "11.0.15" 2022-04-19 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.15+8-LTS-149) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.15+8-LTS-149, mixed mode) 

This is confusing because my Java compiles (e.g., via mvn) use JDK 8 since that’s what my JAVA_HOME is pointing to. (I’m not even sure where the version 11 it found came from; possibly from when I installed maven.)

Determining the difference between the JRE and JDK you’re running has never been straightforward. Seems like java -version used to be a way to do this, but no longer.

Adding to the complexity, you can also supposedly get your Java version info from Control Panel > Programs > Java > About. For me, that shows Version 8. That’s despite java -version showing version 11.0.15. And it doesn’t change even if I point my JAVA_HOME to JDK 11.

Note that this answer is also helpful. In my case, that helped me determine that I have java.exe and javac.exe at C:\Program Files (x86)\Common Files\Oracle\Java\javapath and C:\Program Files\Common Files\Oracle\Java\javapath . Depending on which one I have listed first in my Path variable, I get different results when i run java -version or java —version . The former seems to work when Java 8 is listed first; the latter when Java 11 is first.

Источник

How to check JDK version in Oracle?

We have a Java class within our Oracle DB and recently one line of code in that java class is throwing an error:

static BASE64Encoder B64 = new BASE64Encoder(); 

on this line of code. I am not sure what has changed on the DB side as we don’t have SYS privileges or access to host. I wish to check the JDK version running our Oracle DB —

3 Answers 3

SELECT dbms_java.get_ojvm_property(PROPSTRING=>'java.version') FROM dual 

solution 1) on the database host

cd $ORACLE_HOME/jdk/bin java -version 

solution 2) create a PL/SQL function to return Java system properties

create function get_java_property(prop in varchar2) return varchar2 is language java name 'java.lang.System.getProperty(java.lang.String) return java.lang.String'; 

And the run a select for the Java version

select get_java_property('java.version') from dual; 

solution 3) check the answer from SteveK

If you have the grant to create a PL/SQL function use the second solution I posted. Otherwise if you have no access to the database host nor have the grant to create a PL/SQL function you could rely on the list of certified versions or ask someone who administrate the server.

Читайте также:  Php api android app

@KarstenSpang Could you please provide an example in which official Oracle database setup it would be not the case. (It might be that within the last five years there is now such a case.)

Oracle 12.2 / 18.1 JVM is 1.8

The Oracle 12c database embedded JVM supports JDK 1.6 and 1.7

The Oracle 11g >= 11.2.0.4 database embedded JVM supports JDK 1.6

The Oracle 11g database embedded JVM supports JRE 1.5.

The Oracle 10g database embedded JVM supports JRE 1.4.

The Oracle 9i database embedded JVM supports JRE 1.3

Where have you find this info? I am searching it on the internet but only found your post that is absolutelly right.. but from where you copied that?

I was trying to update jdk up to 8 by update_javavm_binaries.pl but saw that Valid options are: 6 7, Then was trying to make somehow jdk 8 available inside /u01/app/oracle/product/12.1.0/dblb/javavm/jdk but couldn’t .. I was searching supporting matrix on metalink, on google but couldn’t find that.. Your post made me clear where I was wrong.. So thank you!

Источник

how to check the jdk version used to compile a .class file [duplicate]

error in java, is there a way for me to check which version the .class files are? I’m using JRE1.5.0_6 , but my JDK is version 1.6.0_13. I’m compiling with compatibility mode set to 1.5 in eclipse which I thought would work.

5 Answers 5

You’re looking for this on the command line (for a class called MyClass):

javap -verbose MyClass | grep "major" 
javap -verbose MyClass | findstr "major" 

You want the major version from the results. Here are some example values:

Java Version Major Version
1.2 46
1.3 47
1.4 48
5 49
6 50
7 51
8 52
9 53
10 54
11 55
12 56
13 57
14 58
15 59
16 60
17 61
18 62
19 63
20 64

Alternatively, if you open the class file in a hex editor you can look at bytes 7 and 8. The number will map to the numbers given in the above answer. E.g. 00 2E -> JDK 1.2 = 46 (0x2E hex). Useful if you don’t have access to javap. ref: en.wikipedia.org/wiki/Java_class_file#General_layout

I had to remove the «.class» in the command otherwise I got a message, «Error: Cannot find foo.class». So doing, «javap -verbose foo | grep «major»» worked. Just a heads up. stackoverflow.com/questions/13356811/…

As Jim advises, for vi addicts: «vi MyClass» then » :!xxd» then peep at byte 8; 0x31, 0x32, 0x33, 0x34, 0x35 stands for java 5, 6, 7, 8, 9 respectively. » :q!» to exit vi.

So I was working on a project that uses amazon sdk. The project uses Java 1.7. If I check inside of the MANIFEST.MF of amazon sdk it says Build-Jdk: 1.8.0_111 , but if I use javap -verbose MyClass | grep «major» it says major version: 50 which means Java Version 6. This is confusing. Does that mean — even though it was compiled with 8 but it can run on 6?

Источник

Оцените статью