I have the following code in netbeans (using javafx in the same project):
public class ExperimentControler {
public static HashMap<String,Double> userInput = null;
public static ObservableMapWrapper<String,Double> userInputObservable = null;
}
and
static final String totalDistance = "Total distance";
public static void main(String[] args) {
ExperimentControler.userInput = new HashMap<String,Double>();
ExperimentControler.userInput.put(totalDistance, 300.0);
ExperimentControler.userInputObservable = new ObservableMapWrapper<String,Double>(ExperimentControler.userInput);
Application.launch(PhysicsGui.class, args);
}
@Override
public void start(Stage primaryStage) {
ExperimentControler.userInput.get(totalDistance);
//...
}
This is working perfectly inside netbeans.
If I “clean and build” the project, the resulted .jar file throws a null pointer exception on this line:
ExperimentControler.userInput.get(totalDistance);
Also, this is my java version outside of netbeans:
>java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
I also tried with jre 1.7.0 but the results were exactly the same..
In netbeans I have jdk 1.6.0_26.
OK… thanks to Kal’s comment:
I figured out that the following (javafx) code (must be this.. there is no other entry point):
bypasses the main() when I run it as standalone. Maybe the root cause is totally different I don’t know..
The fact is that in netbeans, main() is running and on the standalone is not..
I also checked the jar’s manifest and the main-class is correct. (just in case)
My mind could not go to the fact that main is not running at all !
So, I moved the code I had in main() to the overrided start method and it works.
The specification says that the start() method is the main entry point for javafx applications.
But, in my understanding, main() should still be called before start().. this could be a bug on javafx.