Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An unsupported Java version was detected. Java 17. Oracle OpenJDK #5358

Closed
viktor-saranchuk opened this issue Jan 24, 2024 · 12 comments
Closed

Comments

@viktor-saranchuk
Copy link

I have installed Java 17 on a laptop, Java Home is set but I still receive "An unsupported Java version was detected." message.
image

OS Details:
Edition Windows 11 Enterprise
Version 21H2
Installed on ‎10/‎27/‎2023
OS build 22000.2652
Experience Windows Feature Experience Pack 1000.22001.1000.0

image

I set Java Home and have updated Path variable.
In the VS Code Apex extension settings I tried to set up Java Home there in a different ways:
in settings

C:\Program Files\Java\jdk-17
C:\Program Files\Java\jdk-17\bin

In settings.json file it was represented with double backslashes.

Even if I remove this setting or leave it empty, the Apex extension doesn't use the one set in path or JAVA_HOME

**java -version**
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)

**Get-Command java**
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     java.exe                                           17.0.0.0   C:\Program Files\Java\jdk-17\bin\java.exe

The installed java is Oracle OpenJDK(x64)_17.0_L_EN_01.
The laptop belongs to a company, so I can not install everything without bureaucracy and chain of approvals.

**sf --version**
@salesforce/cli/2.23.20 win32-x64 node-v20.10.0

**sfdx --version**
@salesforce/cli/2.23.20 win32-x64 node-v20.10.0

image

Apex extension version v59.13.0
image

VS Code version 1.85.2
image

@daphne-sfdc
Copy link
Contributor

Hi @Blackbackroom,
Your original input of C:\Program Files\Java\jdk-17 was the correct format, and the double backslashes in settings.json are supposed to be there. Did you reload the VSCode window after setting your Java Home? Settings don't activate with the new behavior until you reload the window.

@viktor-saranchuk
Copy link
Author

Hi @daphne-sfdc
The input for java home is correct. I just mentioned that to assure that backslashes are escaped in settings.json.

I closed and opened the settings window, did the same with the VS Code itself. And nothing. The error persists.
Actually, I am struggling with this issue for about a month and only now I decided to open the ticket.

@peternhale
Copy link
Contributor

@Blackbackroom It appears the values we use to check in parsing the results of the java -version command is not able to pick up that your version as valid.

Is your from an Oracle install?

@viktor-saranchuk
Copy link
Author

@peternhale
The laptop belongs to company (global corporation) therefore I am not able to install something by myself. So the laptop is maintained by a corporates system admin.

I requested to install Oracle OpenJDK 17.
The corporation uses only verified sources of software to install.
So I am pretty sure that the OpenJDK is from Oracle -> OpenJDK(x64)_17.0_L_EN_01

I can not quickly switch to a different version of Java. TBH, to set the current version of JAVA_HOME was challenging.
I raised a ticket and waited for 4 days.

image

@peternhale
Copy link
Contributor

@Blackbackroom What I am seeing is a slight difference between how Oracle release of OpenJdk 17 is displaying version vs what we typically see.

We use java -version command in the apex extension to vet java version. For the version of java I have installed (Zulu) the results look like this.

java -version
openjdk version "17.0.7" 2023-04-18 LTS
OpenJDK Runtime Environment Zulu17.42+20-SA (build 17.0.7+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.42+20-SA (build 17.0.7+7-LTS, mixed mode, sharing)

In the results we are looking for the string build 17. for JDK, but in your install I see build 17+, which is why I believe you are getting the error.

If you would run java -XshowSettings:properties and share the results with. It is going to produce a couple of pages of output, so be mindful of sensitive info before posting the results.

This new command line option was introduced in java 9. I will see if this approach would provide a more reliable way of determining java version.

@viktor-saranchuk
Copy link
Author

@peternhale

Property settings:
    file.encoding = Cp1252
    file.separator = \
    java.class.path =
    java.class.version = 61.0
    java.home = C:\Program Files\Java\jdk-17
    java.io.tmpdir = C:\Users\SARANVI1\AppData\Local\Temp\4\
    java.library.path = C:\Program Files\Java\jdk-17\bin
        C:\WINDOWS\Sun\Java\bin
        C:\WINDOWS\system32
        C:\WINDOWS
        C:\Program Files\Java\jdk-17\bin
        C:\Program Files\Python310\Scripts\
        C:\Program Files\Python310\
        C:\Program Files (x86)\Common Files\Oracle\Java\javapath
        C:\ProgramData\Oracle\Java\javapath
        C:\WINDOWS\system32
        C:\WINDOWS
        C:\WINDOWS\System32\Wbem
        C:\WINDOWS\System32\WindowsPowerShell\v1.0\
        C:\WINDOWS\System32\OpenSSH\
        C:\Program Files\1E\Client\Extensibility\NomadBranch
        C:\Program Files\Git\cmd
        C:\Program Files (x86)\nodejs\
        C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
        C:\Program Files\sf\bin
        C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm
        C:\Program Files\Java\jdk-17\bin
        C:\Users\SARANVI1\AppData\Local\Microsoft\WindowsApps
        C:\Users\SARANVI1\AppData\Local\Programs\Microsoft VS Code\bin
        C:\Program Files\sf\bin

        .
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 17+35-LTS-2724
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Oracle Corporation
    java.specification.version = 17
    java.vendor = Oracle Corporation
    java.vendor.url = https://java.oracle.com/
    java.vendor.url.bug = https://bugreport.java.com/bugreport/
    java.version = 17
    java.version.date = 2021-09-14
    java.vm.compressedOopsMode = Zero based
    java.vm.info = mixed mode, sharing
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Oracle Corporation
    java.vm.specification.version = 17
    java.vm.vendor = Oracle Corporation
    java.vm.version = 17+35-LTS-2724
    jdk.debug = release
    line.separator = \r \n
    native.encoding = Cp1252
    os.arch = amd64
    os.name = Windows 10
    os.version = 10.0
    path.separator = ;
    sun.arch.data.model = 64
    sun.boot.library.path = C:\Program Files\Java\jdk-17\bin
    sun.cpu.endian = little
    sun.cpu.isalist = amd64
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = Cp1252
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers
    sun.os.patch.level =
    sun.stderr.encoding = cp437
    sun.stdout.encoding = cp437
    user.country = US
    user.dir = C:\Users\SARANVI1
    user.home = C:\Users\SARANVI1
    user.language = en
    user.name = SARANVI1
    user.script =
    user.variant =

Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)
   or  java [options] <sourcefile> [args]
           (to execute a single source-file program)

 Arguments following the main class, source file, -jar <jarfile>,
 -m or --module <module>/<mainclass> are passed as the arguments to
 main class.

 where options include:

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -p <module path>
    --module-path <module path>...
                  A ; separated list of directories, each directory
                  is a directory of modules.
    --upgrade-module-path <module path>...
                  A ; separated list of directories, each directory
                  is a directory of modules that replace upgradeable
                  modules in the runtime image
    --add-modules <module name>[,<module name>...]
                  root modules to resolve in addition to the initial module.
                  <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
                  ALL-MODULE-PATH.
    --enable-native-access <module name>[,<module name>...]
                  modules that are permitted to perform restricted native operations.
                  <module name> can also be ALL-UNNAMED.
    --list-modules
                  list observable modules and exit
    -d <module name>
    --describe-module <module name>
                  describe a module and exit
    --dry-run     create VM and load main class but do not execute main method.
                  The --dry-run option may be useful for validating the
                  command-line options such as the module system configuration.
    --validate-modules
                  validate all modules and exit
                  The --validate-modules option may be useful for finding
                  conflicts and other errors with modules on the module path.
    -D<name>=<value>
                  set a system property
    -verbose:[class|module|gc|jni]
                  enable verbose output for the given subsystem
    -version      print product version to the error stream and exit
    --version     print product version to the output stream and exit
    -showversion  print product version to the error stream and continue
    --show-version
                  print product version to the output stream and continue
    --show-module-resolution
                  show module resolution output during startup
    -? -h -help
                  print this help message to the error stream
    --help        print this help message to the output stream
    -X            print help on extra options to the error stream
    --help-extra  print help on extra options to the output stream
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:jdwp
                  see also -agentlib:jdwp=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
                  HiDPI scaled images are automatically supported and used
                  if available. The unscaled image filename, e.g. image.ext,
                  should always be passed as the argument to the -splash option.
                  The most appropriate scaled image provided will be picked up
                  automatically.
                  See the SplashScreen API documentation for more information
    @argument files
                  one or more argument files containing options
    -disable-@files
                  prevent further argument file expansion
    --enable-preview
                  allow classes to depend on preview features of this release
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.

Copy link

git2gus bot commented Jan 24, 2024

This issue has been linked to a new work item: W-14888195

@peternhale
Copy link
Contributor

@Blackbackroom I logged a bug.

@daphne-sfdc
Copy link
Contributor

Closing this issue as the PR has been merged and released in v59.16.0.

@diyer
Copy link
Collaborator

diyer commented Feb 1, 2024

@Blackbackroom Can you please verify the fix on your end and let us know if this has resolved the issue?

@viktor-saranchuk
Copy link
Author

viktor-saranchuk commented Feb 1, 2024

Hi @diyer
Confirm!
The issue is solved!

Thank you

@diyer
Copy link
Collaborator

diyer commented Feb 1, 2024

Thanks to @peternhale for fixing this!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants