This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 225655 - 7.3 Release Candidate One - Java Editor spuriously flags all JavaFx references as errors
Summary: 7.3 Release Candidate One - Java Editor spuriously flags all JavaFx reference...
Status: RESOLVED WORKSFORME
Alias: None
Product: javafx
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Petr Somol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-01 23:58 UTC by djkinmaine12
Modified: 2013-02-06 12:56 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description djkinmaine12 2013-02-01 23:58:41 UTC
Unless you put a specific reference to jfxrt.jar via Project Properties Libraries, every JavaFx reference in the code is marked as an error.
Visual only, file compiles and project builds work ok (Clean and Build Main Project).
This is infuriating because every time you upgrade to a new Java version, all these references have to be updated to point to the jfxrt.jar in the new version.

To recap:
with C:\Program Files\Java\jdk1.7.0_12\jre\lib\jfxrt.jar in Libraries - no errors flagged. 
Without  - a "zillion"  false errors
Comment 1 Marian Mirilovic 2013-02-03 20:23:26 UTC
Petr, please evaluate ... thanks in advance.
Comment 2 Petr Somol 2013-02-04 12:46:53 UTC
jfxrt.jar is not on classpath by default in all JDK7 despite the fact that FX is distributed as part of JDK7 since 7u6. For exactly this reason NB provides support for FX-enabled Java platforms. To make things easier for users, a platform named Default JavaFX Platform is created the first time a JavaFX Application is created or opened. Default JavaFX Platform is a wrapper around the Java Platform that was default at the time of Default JavaFX Platform creation, whose only purpose is to add jfxrt.jar on classpath. Apart from Default JavaFX Platform, users can create FX-enabled platforms manually - in Tools->Java Platforms create a new Java Platform, then go to JavaFX tab and click Enable JavaFX checkbox. The paths to FX SDK and RT should be auto-detected.

What puzzles me is the fact that you are able to compile, despite the fact that all FX references are marked as erroneous - that would point at missing jfxrt.jar classpath reference, in NB context that would mean the project has a non-FX-enabled Java Platform selected (see Project Properties->Libraries) or the definition of the platform itself may be corrupted.

How have you created your NB project ? If you started from a Java->Java Application instead of JavaFX->JavaFX Application, then this might be the problem - FX Applications differ not only by the need to have jfxrt.jar on classpath, but the whole build system is different..

Please try to run NB7.3 from a clean userdir, this should prevent problems coming from potentially corrupted old platform definitions. Try to create a new JavaFX Application - the Default JavaFX Platform should get created automatically and the Application should behave as expected. With JDK7u12 that you use the automatic platform creation should work OK (I have just verified it does on my PC).
Comment 3 Petr Somol 2013-02-06 12:02:16 UTC
I am copying here Dennis's e-mail response:

I forgot to add that the main project has depends on two other projects. No doubt the jfxrt.jar was picked up when the "Build Projects on Classpath" option was invoked.

I'm running Windows7 
Following your advice I created a new empty cache and userdir. I said yes when asked if I wanted to import preferences found in the NetBeans 7.0 dir.

Following your advice, I created a new JavaFx FXML Application
Visual Bug - After creating the project, I right-clicked on the project name, selected properties and brought up the Project Properties dialog and went to the Libraries on the tree pane.  At the bottom, above the buttons  there was a notice "Some library items cannot be located. Use the Reference Problems dialog.  I did a clean and build and the spurious notice disappeared.


After I did this, I did get the "Default JavaFx Platform" option displayed in my working projects. However things did not go swimmingly .... I've attached a project properties file in which there are comments put in by the NetBeans program that says, "seems not to work" .....  Maybe something to do with endorsed.classpath?

To get around this mess, I created a new JavaFX FXML application, and copied the project.properties files into my existing projects. I had to copy the jfx-impl.xml file too. 

My main project still doesn't show the same jars as the project I created with the empty userdir, but the two dependent projects do, and that's good enough for the time being. 

---------
The e-mail had a project.properties file attached from which the relevant section is as follows:

# seems not work. try coping over from CatalystJavaFX ... file javafx.runtime=${platforms.Default_JavaFX_Platform.javafx.runtime.home}
# seems not work. try coping over from CatalystJavaFX ... file javafx.sdk=${platforms.Default_JavaFX_Platform.javafx.sdk.home}
javafx.runtime=${platforms.JDK_1.7_0_12.javafx.runtime.home}
javafx.sdk=${platforms.JDK_1.7_0_12.javafx.sdk.home}
Comment 4 Petr Somol 2013-02-06 12:56:52 UTC
(In reply to comment #3)
> Following your advice, I created a new JavaFx FXML Application
> Visual Bug - After creating the project, I right-clicked on the project name,
> selected properties and brought up the Project Properties dialog and went to
> the Libraries on the tree pane.  At the bottom, above the buttons  there was a
> notice "Some library items cannot be located. Use the Reference Problems
> dialog.  I did a clean and build and the spurious notice disappeared.

This particular nuisance is indeed present but does not affect functionality; it got accepted temporarily when the former FX support was created as an extension of SE support. The handling of FX platforms will be changed from scratch in NB8.

> After I did this, I did get the "Default JavaFx Platform" option displayed in
> my working projects. However things did not go swimmingly .... I've attached a
> project properties file in which there are comments put in by the NetBeans
> program that says, "seems not to work" .....  Maybe something to do with
> endorsed.classpath?

Mixing non-FX project.properties with those from FX projects may lead to problems you describe. 
The key properties in a FX project.properties file are javafx.sdk and javafx.runtime which should point at valid FX SDK/RT location. FX support in NB up to 7.3 aims at providing the option to define various FX-enabled Java platforms; users might have various JDKs and/or FX SDKs installed, and may want to switch between them for various reasons. Project properties are therefore maintained so as not to store hardcoded paths. Instead, they refer to FX-enabled Java platform name. 
A FX-enabled platform is created automatically (cf. Default JavaFX Platform) or can be created manually in Tools->Java Platforms->Add Platform.., where user can give the new platform any name and assign a valid FX SDK/RT reference. Once a FX-enabled platform is created, its definition is stored in current userDir. See build.properties in it. In your projects the original platform name seems to have been "JDK 1.7 0 12", as the project.properties file contained reference to variable platforms.JDK_1.7_0_12.javafx.sdk.home. If such projects, with non-default FX-platform, got copied to another NB instance where such FX platform did not exist, the projects would not compile unless the platform definition is manually created.
It was to avoid exactly this problem that the Default JavaFX Platform has been introduced. Such platform gets auto-created (the process should succeed on almost all machines, with the exception of those with FX SDK installed to non-standard location) on first opening or creation of a FX project. Projects referring to Default JavaFX Platform can then be transferred to other machines without any additional effort - the definition of Default JavaFX Platform on particular machine may differ but the name is same, thus the project should build/run correctly without need of user intervention.

To summarize: project.properties of a FX project must refer to a valid FX-enabled Java platform, so assuming your NB installation has successfully auto-created Default JavaFX Platform, then your project.properties files should contain

javafx.runtime=${platforms.Default_JavaFX_Platform.javafx.runtime.home}
javafx.sdk=${platforms.Default_JavaFX_Platform.javafx.sdk.home}
platform.active=Default_JavaFX_Platform

so that through 

endorsed.classpath=\
    ${javafx.runtime}/lib/jfxrt.jar:\
    ${javafx.runtime}/lib/deploy.jar:\
    ${javafx.runtime}/lib/javaws.jar:\
    ${javafx.runtime}/lib/plugin.jar

all needed FX artifacts get added to the classpath. Note that changing a platform for a project (Project Properties->Libraries->Java Platform) updates the relevant properties.

I have just verified that these mechanisms work as expected in a cleanly created FX project with JDK6 as well as with current JDK7.