3

This machine has had multiple version of Java JDK installed and multiple version of multiple IDEs (Netbeans, IntelliJ, Eclipse, etc.) Most recently, I have added JDK 15.0.2 and Netbeans 12.2. When trying to compile a simple "Hello World", this is the output that results:

ant -f C:\\Data\\NetBeans\\grading\\TestGrading -Dnb.internal.action.name=run.single -Djavac.includes=testgrading/HelloWorld.java -Drun.class=HelloWorld run-single

init:

Deleting: C:\Data\NetBeans\grading\TestGrading\build\built-jar.properties

deps-jar:

Updating property file: C:\Data\NetBeans\grading\TestGrading\build\built-jar.properties

Compiling 1 source file to C:\Data\NetBeans\grading\TestGrading\build\classes

**warning: [options] system modules path not set in conjunction with -source 11**

**1 warning**

compile-single:

run-single:

Hello World!

BUILD SUCCESSFUL (total time: 1 second)

As you can see, the file compiles and runs, but the warning is causing me concern. I have not been able to find a similar warning in my searches... (all of the warnings refer to "bootstrap class path not set" instead of "system modules path not set"

I have updated my Environment Variable to reflect the most current JDK with this entry: JAVA_HOME=C:\Program Files\Java\jdk-15.0.2

What setting am I missing that wasn't properly updated as I've updated my JDK and my IDE? Or am I completely looking in the wrong places? Or do I need to fully uninstall previous versions and, if so, what will that do to previous code written using those previous versions that I'd still like to retain?

Thanks in advance!

Jens
  • 67,715
  • 15
  • 98
  • 113
WeberEInc
  • 91
  • 1
  • 6
  • Consider reading up the modules feature. It seems recent version of java are throwing the warnings and suggesting that you use the modules feature in your code. http://tutorials.jenkov.com/java/modules.html – vvs Feb 05 '21 at 18:24
  • Jens -thank you for your comment and your pitch for Java Modules, but this doesn't answer my specific question about this specific warning message and how I can go about resolving it. Warning message should be easily decipherable - not cryptic without resource to resolve them. – WeberEInc Feb 13 '21 at 23:05
  • 1
    The warning is as with many system messages is indeed cryptic. Assume you are using - source 11 somewhere in the javac command used for the build. Please try adding - - release 11 and rerun the build. That should fix this – vvs Feb 13 '21 at 23:42
  • 1
    I stumbled on the issue and the fix! While the new install changed the Java Platform in the Libraries properties to correctly point to JDK 15 as the new (Default), in the Sources area, towards the bottom, it left the Source/Binary Format still showing JDK 11. Changing this manually to JDK 15 made the warning go away. The warning message should have said something to the effect of "Source/Binary Format" does not match Library Java Platform - check corresponding versions." – WeberEInc Feb 14 '21 at 00:53
  • @WeberElnc The warning doesn't say about source format since in java it's a perfectly valid scenario to use a later version of jdk (15) and want to compile with compatibility level of an older version (11). Usually changing the version for compiling can be non trivial exercise especially if the source code uses classes or methods that have been deprecated in later versions. In such a case changing compile version would involve code rewrite. – vvs Feb 14 '21 at 01:33

4 Answers4

5

I stumbled on the issue and the fix! While the new install changed the Java Platform in the Libraries properties to correctly point to JDK 15 as the new (Default), in the Sources area, towards the bottom, it left the Source/Binary Format still showing JDK 11. Changing this manually to JDK 15 made the warning go away. The warning message should have said something to the effect of "Source/Binary Format" does not match Library Java Platform - check corresponding versions."

WeberEInc
  • 91
  • 1
  • 6
  • 2
    Took me a little effort to understand your solution (which worked - thanks!), so to clarify for others: In Netbeans, right click on project and go to Properties. Then look at Sources. As stated above, the Source / Binary Format will specify an older version of the JDK, so use the dropdown to update that value (in my case, JDK 11 --> JDK 15). – Philip H May 10 '21 at 14:34
0

It is sometimes happened because of java updates. When the newer version is needed,it says you to remove the older version. If you didn't do that this cause come confusing. You can better use older versions to solve this problem. Maybe this can help you.

isilacar
  • 1
  • 2
  • Isilacar - unfortunately, the install process of the newer version did not warn about removing the old version and did not say that there would be any issues. Shouldn't Java documentation include a way to troubleshoot these warnings? – WeberEInc Feb 13 '21 at 23:07
-1

I had this exact same warning, which in my case ended up as an error and caused build to fail when runnning mvn commands. I was using jdk 16 and also had 11 installed. In my case, nothing has fixed it except to fully uninstall java from my mac and reinstall the versions I needed from https://adoptopenjdk.net/.

Laszlo Sarvold
  • 733
  • 7
  • 15
-1

You need to update your JAVA_HOME environment variable.

On Mac update your ~/.bash_profile or ~/.zshrc. Make sure you have the version you want installed and make -v## the version you want to use. For example,

To use Java 11,

export JAVA_HOME=`/usr/libexec/java_home -v11` 

To use Java 17,

export JAVA_HOME=`/usr/libexec/java_home -v17` 

On Windows change you system environment variable to your new java version.

Heres how! (Confluence)