Hello again. Now I'm a little suspicious on whether your problem is caused by ANT picking JDK 15 to compile. The presence of JDK 15 properties doesn't mean that it's using it to compile,
>In build output in debug mode, it shows "Detected Java version 15" and "Java >Version: 15.0.1" See, in my small JDK8 test project I still get "Detected Java version: 11 in: /home/juan/.sdkman/candidates/java/11.0.7.hs-adpt" at the start, but I know it's using JDK8 because of the aforementioned test. Also I put a main method with System.out.println(System.getProperty("java.version")); and ran it with Run -> Run File and printed the expected 1.8.0_252 Also here's a sample of some of my properties in that project printed using <echoproperties />: platform.home=/home/juan/.sdkman/candidates/java/8.0.252.hs-adpt jdk.home=/home/juan/.sdkman/candidates/java/11.0.7.hs-adpt java.runtime.version=11.0.7+10 java.version=11.0.7 default.javac.target=11 javac.source=1.8 java.home=/home/juan/.sdkman/candidates/java/11.0.7.hs-adpt platform.javac.tmp=${platforms.JDK_8.0.252.hs-adpt.javac} platform.active=JDK_8.0.252.hs-adpt java.vm.version=11.0.7+10 platform.javac=/home/juan/.sdkman/candidates/java/8.0.252.hs-adpt/bin/javac java.vm.specification.version=11 platform.compiler=${platforms.JDK_8.0.252.hs-adpt.compile} platform.home=/home/juan/.sdkman/candidates/java/8.0.252.hs-adpt platforms.JDK_8.0.252.hs-adpt.compiler=modern platform.java=/home/juan/.sdkman/candidates/java/8.0.252.hs-adpt/bin/java platforms.JDK_8.0.252.hs-adpt.home=/home/juan/.sdkman/candidates/java/8.0.252.hs-adpt platform.active=JDK_8.0.252.hs-adpt platforms.JDK_11.0.7.hs-adpt.home=/home/juan/.sdkman/candidates/java/11.0.7.hs-adpt platform.compiler=${platforms.JDK_8.0.252.hs-adpt.compile} As you can see, there are a lot of JDK 11 related properties, but probably the ones that determine the JDK used to compile are platform.active (probably the most important one, and the one that is set by the project properties dialog), platform.javac and the "platforms.<value set in platform.active>" properties > wsimport is not present in JDK15 What error message do you get? Does it actually report that C\:\\Program Files\\Java\\jdk1.8.0_271\\bin\\wsimport is not found or does the error message point to JDK15? if so, how does it detect the path to wsimport? through a property or environment variable? Is it a special tag that you imported to ant or a custom cmd call through ant? >Even if I temporarily skip wsimport target, it later fails on not finding >classes/packages like com.sun.tools.internal.xjc.XJCFacade, >javax.xml.bind.annotation (just like you mentioned) I tried importing com.sun.tools.internal.xjc.XJCFacade on my test project using JDK8 and it couldn't find it either! Since it has "sun" in the package I thought that maybe it was an issue with the JDK vendor (both my JDK 8 and 11 on my Ubuntu computer are AdoptOpenJDK) so just to be sure I went to a different computer that still has Netbeans 8.2 running on an Oracle provided JDK 1.8.0_172 and uses Windows (so pretty close to your setup) on a new Ant web application project, and can't find that class either. On that particular computer none of the <echoproperties /> point to anything JDK11 related and JDK8 is the one in the PATH. In fact I can't find XJCFacade it in the list of all JDK 8 classes: https://docs.oracle.com/javase/8/docs/api/allclasses-noframe.html And yet it works in your NB 8 installation, Could you CTRL+Click that class and hover over the tab name to find out exactly where it's getting it from? Is it from the JDK or a dependency? If it's from the JDK exactly what file is it and what is the vendor of the JDK? Regarding not finding the javax.xml.bind.annotation classes I don't have an answer for that, but seeing what happened with XJCFacade maybe you could provide a concrete example of one of the classes that is not found so I can test it out. I also can't explain why it works if you make netbeans run on JDK8 trough netbeans.conf. Again, I tested NB8.2 running on JDK8 and couldn't find that class. Also I see that you're still using Compile on Save (j2ee.compile.on.save=true) Could you turn it off to see if it makes a difference? This affects not only the editor, but also when you compile using F9/F11 and nb-javac was way more stable in Netbeans 8. Let me know what you think On Sat, Jan 23, 2021 at 9:16 AM Karan Agrawal <karan....@gmail.com> wrote: > > Hi Juan, > > Platform update is done through the window; did not modify project.properties > file manually. > > There is one modification to generate Java classes from a wsdl file, using > "wsimport" which is present in JAVA_HOME/bin. > This, however, works well as long as JDK 8 is used. Build file is working > with Netbeans 8.0 and also when netbeans.conf is updated to use JDK 8 in NB > 12.2 > > It is using JDK15 as: > 1. In build output in debug mode, it shows "Detected Java version 15" and > "Java Version: 15.0.1" > 2. wsimport is not present in JDK15 > 3. Even if I temporarily skip wsimport target, it later fails on not finding > classes/packages like com.sun.tools.internal.xjc.XJCFacade, > javax.xml.bind.annotation (just like you mentioned) > > Here's the dump of properties used by ant (<echoproperties />), trimmed to > important values: > #Ant properties > #Sat Jan 23 21:18:00 IST 2021 > sun.boot.library.path=C\:\\Program Files\\Java\\jdk-15.0.1\\bin > platform.home=C\:\\Program Files\\Java\\jdk1.8.0_271 > j2ee.copy.static.files.on.save=true > jdk.home=C\:\\Program Files\\Java\\jdk-15.0.1 > java.runtime.version=15.0.1+9-18 > platform.bootcp=C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\resources.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\rt.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\sunrsasign.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\jsse.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\jce.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\charsets.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\jfr.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\classes;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\access-bridge-64.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\cldrdata.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\dnsns.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\jaccess.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\jfxrt.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\localedata.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\nashorn.jar;C\:\\Program > Files\\Java\\j > dk1.8.0_271\\jre\\lib\\ext\\sunec.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunjce_provider.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunmscapi.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunpkcs11.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\zipfs.jar > java.version=15.0.1 > java.vm.specification.version=15 > platform.javac=C\:\\Program Files\\Java\\jdk1.8.0_271/bin/javac > default.javac.target=15 > env.JAVA_HOME=C\:\\Program Files\\Java\\jdk1.8.0_271 > j2ee.compile.on.save=true > netbeans.productversion=Apache NetBeans IDE 12.2 > var.JAVA_HOME=C\:\\Program Files\\Java\\jdk1.8.0_271\\jre > platform.javac.tmp=${platforms.JDK1.8.0_271.javac} > j2ee.platform=1.5 > netbeans.hash.code=unique\=0b09b7857-fb3d-4fce-a2b9-4c7a0a1e30a5_18c83404-17e7-456c-8e25-33db84559846 > javac.source=1.8 > java.home=C\:\\Program Files\\Java\\jdk-15.0.1 > platforms.JDK1.8.0_271.compiler=modern > platforms.JDK1.8.0_271.home=C\:\\Program Files\\Java\\jdk1.8.0_271 > platform.active=JDK1.8.0_271 > default.javac.source=15 > platform.javadoc.tmp=${platforms.JDK1.8.0_271.javadoc} > platform.java.tmp=${platforms.JDK1.8.0_271.java} > ant.home=<PATH>\\netbeans\\extide\\ant > javac.target=1.8 > ant.version=Apache Ant(TM) version 1.10.8 compiled on May 10 2020 > ant.java.version=15 > platforms.JDK1.8.0_271.bootclasspath=C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\resources.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\rt.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\sunrsasign.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\jsse.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\jce.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\charsets.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\jfr.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\classes;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\access-bridge-64.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\cldrdata.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\dnsns.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\jaccess.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\jfxrt.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\localedata.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\nashorn.jar;C\:\\P > rogram Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunec.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunjce_provider.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunmscapi.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\sunpkcs11.jar;C\:\\Program > Files\\Java\\jdk1.8.0_271\\jre\\lib\\ext\\zipfs.jar > platform.compiler=${platforms.JDK1.8.0_271.compile} > java.vm.version=15.0.1+9-18 > > > As you can see, many properties related to java are pointing to JDK 15. > Any workaround? > > Thanks, > Karan > On 2021/01/23 12:53:32, Juan Algaba <jalg...@colef.mx> wrote: > > Hello, here's my two cents: > > > > > Therefore, after opening the projects in Netbeans 12.2, I have added JDK8 > > > in the platform and updated Project Properties accordingly. > > Just to confirm, you did this through the project properties window > > and not by manually editing project.properties correct? > > Speaking of which, what are your current values in that file for > > platform.active, javac.source and javac.target? > > Do you have any customizations in build.xml, or god forbid build-impl.xml? > > > > > With Netbeans 12.2, when "clean and build" is triggered, ANT picks JDK 15 > > > and compilation fails. > > How do you know that ANT picks JDK 15? Do it says so explicitly in the > > output or do you assume so because the compilation error consists of a > > missing class that is no longer > > in the JDK or something like that? > > I ask this because even looking at the output in verbose mode I find > > it difficult to be sure because in my computer NB runs on JDK 11, and > > even when compiling with a JDK 8 > > the output always start with "Detected Java version: 11 in: ...", but > > I know it's compiling with the JDK8 that I set because I did a test > > (more on that later). > > > > >Q. How to make ANT pick the JDK mapped to the project in > > >project.properties? > > It should work the way you did it, which is going to the project > > properties -> Libraries -> Java Platform, and selecting JDK8 from the > > dropdown menu (and adding it with the > > platform manager button if necessary). > > The result should be that the value in project.properties changed from > > platform.active=default_platform to platform.active=JDK_8 > > So verify that first, also check that the path to JDK_8 (or whatever > > keyword is set there) actually points to a JDK 8 through the platform > > manager window, remember that this path is a user/netbeans wide value > > that wouldn't appear in the project.properties file or in any part of > > your project (it's in a user properties file outside of netbeans but > > you can check that your project uses such file trough > > <project>/nbproject/private/private.properties) > > > > In the past I also migrated an Ant web application that needed to run > > in JDK 8 from NB8/JDK8 to NB11/JDK 11, and don't remember having this > > problem. But maybe that has changed in 12.2, so I tried creating a new > > project using File -> New Project, added a simple class and of course > > it compiled using JDK 11 (though I had to fix a "Xbootclasspath" error > > message), but then I tried switching to JDK8 through the project > > properties and to my surprise it no longer compiled but it wasn't a > > normal compilation error, something weird like: > > "java.lang.RuntimeException: Java result: 1", I couldn't find out what > > was the cause but it got fixed after going back to the project > > properties and disabling "Compile on Save", > > so I recommend that you also try disabling that feature to see if > > there is a difference (this feature depends on a plugin called > > nb-javac, if the option is grayed out it means that > > the plug in is not installed) > > > > Anyway I tested that NB indeed use different JDK by: > > * Compiling "import javax.xml.bind.JAXB;" with both JDK8 and JDK11 and > > getting the expected results (that class is no longer in the JDK after > > 9) > > * Compiling "var myvar = ""; " with both JDK8 and JDK11 and getting > > the expected results (the var keyword doesn't exist in JDK8) > > So Netbeans 12.2 works as expected when switching JDK on a fresh ANT > > project, Could you check if that's the same case on your computer? > > Then we could discard if it's something wrong with your netbeans > > installation rather than your project. > > > > If the previous test works, maybe you could try copying your source > > files to that new project, without your build.xml personalizations or > > anything from the nbproject folder, if that works then maybe you could > > try adding the rest of your configurations to figure out the problem > > by process of elimination. > > > > Hope it helps. > > > > > > On Thu, Jan 21, 2021 at 4:02 AM Zahid Rahman <zahidr1...@gmail.com> wrote: > > > > > > Have a look at this page. > > > I think the other way to get ANT to run specified JDK may be to specify > > > in the build.xml > > > > > > https://stackoverflow.com/questions/949678/ant-is-using-wrong-java-version > > > > > > > > > Z. > > > > > > https://www.backbutton.co.uk/ > > > ¯\_(ツ)_/¯ > > > ♡۶♡۶ ♡۶ > > > > > > On Thu, 21 Jan 2021, 11:53 Zahid Rahman, <zahidr1...@gmail.com> wrote: > > >> > > >> > Although, JDK8 appears before JDK15 in the System's PATH variable > > >> > > >> > > >> I don't think you should have two JDKs > > >> in the PATH environment variable. It is a but messy. > > >> > > >> ANT picks JDK 15 and compilation fails. > > > >> It looks like ant build script is picking up from PATH. > > >> > > >> if you run java - version get jdk 15 then you are probably picking up > > >> jdk 15 from PATH. > > >> > > >> Why the project is not picking up JDK > > >> from project.properties. > > >> Don't know I don't use ANT much. > > >> > > >> > > >> If you are having more than one netbeans IDE on the same machine then > > >> netbeans.conf is provided so that you can point to the preferred jdk > > >> for that IDE. > > >> > > >> > > >> > > >> Z. > > >> > > >> https://www.backbutton.co.uk/ > > >> ¯\_(ツ)_/¯ > > >> ♡۶♡۶ ♡۶ > > >> > > >> On Thu, 21 Jan 2021, 11:13 Karan Agrawal, <karan....@gmail.com> wrote: > > >>> > > >>> Yes Zahid. > > >>> > > >>> The point is - I would be using Netbeans for Java 11+ projects as well. > > >>> Although, JDK8 appears before JDK15 in the System's PATH variable > > >>> > > >>> If I make a change in netbeans.conf, then I will have to start at least > > >>> 2 instances of netbeans and also install nb-javac (probably) > > >>> > > >>> On Thu, Jan 21, 2021 at 4:24 PM Zahid Rahman <zahidr1...@gmail.com> > > >>> wrote: > > >>>> > > >>>> Just a guess. > > >>>> > > >>>> Do you have JDK 15 installed and included in the windows 10 > > >>>> environment PATH variable ? > > >>>> > > >>>> > > >>>> > > >>>> > > >>>> Z. > > >>>> > > >>>> https://www.backbutton.co.uk/ > > >>>> ¯\_(ツ)_/¯ > > >>>> ♡۶♡۶ ♡۶ > > >>>> > > >>>> On Thu, 21 Jan 2021, 10:45 Karan Agrawal, <karan....@gmail.com> wrote: > > >>>>> > > >>>>> Hello Experts, > > >>>>> > > >>>>> I have migrated from Netbeans 8.0 to Apache Netbeans 12.2 > > >>>>> > > >>>>> My Java Projects uses JDK 8 with ANT. > > >>>>> Therefore, after opening the projects in Netbeans 12.2, I have added > > >>>>> JDK8 in the platform and updated Project Properties accordingly. > > >>>>> > > >>>>> With Netbeans 12.2, when "clean and build" is triggered, ANT picks > > >>>>> JDK 15 and compilation fails. > > >>>>> Q. How to make ANT pick the JDK mapped to the project in > > >>>>> project.properties? > > >>>>> > > >>>>> System Details > > >>>>> > > >>>>> Product Version: Apache NetBeans IDE 12.2 > > >>>>> > > >>>>> Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2 > > >>>>> > > >>>>> Java: 15.0.1; Java HotSpot(TM) 64-Bit Server VM 15.0.1+9-18 > > >>>>> > > >>>>> Runtime: Java(TM) SE Runtime Environment 15.0.1+9-18 > > >>>>> > > >>>>> System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb) > > >>>>> > > >>>>> User directory: C:\Users\xxx\AppData\Roaming\NetBeans\12.2 > > >>>>> > > >>>>> Cache directory: C:\Users\xxx\AppData\Local\NetBeans\Cache\12.2 > > >>>>> > > >>>>> > > >>>>> ANT_HOME: <PATH>\extide\ant > > >>>>> > > >>>>> PS: netbeans.conf is one option, but looking for a better alternative. > > >>>>> > > >>>>> Thanks, > > >>>>> Karan > > > > > > > > -- > > > > -Juan Algaba > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org > > For additional commands, e-mail: users-h...@netbeans.apache.org > > > > For further information about the NetBeans mailing lists, visit: > > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org > For additional commands, e-mail: users-h...@netbeans.apache.org > > For further information about the NetBeans mailing lists, visit: > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists > -- -Juan Algaba --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org For additional commands, e-mail: users-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists