The J2SE Platform is not correctly set up.( NetBea

2019-02-16 01:44发布

问题:

I am getting this error while running my program in NetBeans.

nt -f D:\\PMT_LandingPage jfxsa-run
D:\PMT_LandingPage\nbproject\jfx-impl.xml:3725: The following error occurred while executing this line:
D:\PMT_LandingPage\nbproject\build-impl.xml:87: The J2SE Platform is not correctly set up.
 Your active platform is: default_platform, but the corresponding property "platforms.default_platform.home" is not found in the project's properties files. 
 Either open the project in the IDE and setup the Platform with the same name or add it manually.
 For example like this:
     ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.default_platform.home" in a .properties file)
  or ant -Dplatforms.default_platform.home=<path_to_JDK_home> jar (where no properties file is used)
BUILD FAILED (total time: 0 seconds)

I am new with NetBeans and really don't know how to fix it. I googled this issue but could not get any solution.

回答1:

Go to Tools -> Java Platformsand select the correct path to your JDK.



回答2:

ant uses a variable named platform.active for identifiying the java home path. Netbeans should initialize that variable with the correct path, and indeed it does depending on your selected java platform. But, if you select the default platform, netbeans does not assign the correct path to that variable. Instead its value become default_platform. So, in order to correctly find the java path, you should probably change a line like this:

<webproject1:property
  name="platform.home"
  value="platforms.${platform.active}.home"/>

into something like this:

<condition
  property="platform.home"
  value="${java.home}/../"
  else="platforms.${platform.active}.home">
      <equals arg1="${platform.active}" arg2="default_platform" />
</condition>

This checks the value of platform.active and use it, if it is a path, or use the value of java.home instead.