3

How can I specify two names to satisfy a Java dependency? I'm using Netbeans and by default, Linux calls OpenJDK "JDK_7". Windows calls Oracle JDK "JDK 1.7". I would like to make it so that by default either name is acceptable because my code builds the same on both platforms.

Is there a way to specify a "platform" can be either A or B in Netbeans/ant?

4
  • 3
    Add a new platform, pointing to the JDK y want, named they way you want. Commented Jun 2, 2013 at 21:04
  • I'm trying to make it so that it automatically builds without adding a platform.
    – AdamOutler
    Commented Jun 2, 2013 at 22:49
  • Netbeans needs a platform, it rebuilds the buildimpl.xml file each time you open the project and uses the platform information for the project to generate it. Unless you're willing to create you own build.xml for ant, I can't see you have any other choice Commented Jun 2, 2013 at 23:44
  • May I recommend using maven? If you use maven, netbeans can open up your project across platforms without much issue, and you can specify things like the JDK version in a much more cross platform way. For more info see here: wiki.netbeans.org/Maven
    – chamakits
    Commented Jun 3, 2013 at 8:38

3 Answers 3

11

Right click on the project. Then, select "properties". Select "Libraries" from the categories on the left hand side of Project Properties. And then select the new "Java Platform".

5

There are two lines in the nbproject/project.properties file

platform.active=default_platform
platforms.default_platform.home=${java.home}/../ 

These make the Netbeans Platform choose the default platform as the standard platform.

0

In my case, my IDE (Apache NetBeans) did not have the correct version of Java selected (JDK 1.8). The way I solved it was the following:

  1. Right click on the project name, click on "Properties".
  2. Select the "Build" category then "Compile".
  3. In the "Java Platform" section select the JDK 1.8 version.
  4. Click on the "OK" button

If you do not have JDK 1.8 (jdk-8u202) released:

  1. Download from this link: https://www.oracle.com/mx/java/technologies/javase/javase8-archive-downloads.html
  2. Install the downloaded file
  3. In Apache Netbeans go to the "Tools" tab, then "Java Platforms". A "Java Platform Manager" window will open.
  4. In the lower left corner click on the "Add Platform..." button
  5. In the "Select platform type" section, select the "Java Standard Edition" option, click "Next"
  6. Select the JDK 1.8 path. In windows it can be "C:\Program Files\Java\jdk1.8.0_202", click "Next".
  7. Leave the default values, click "Finish". Now follow the steps above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.