1

I'm using Eclipse and have this JavaFX project ready to transform into .jar. Only problem is when i export it and create .jar, it gives me an error on launch. "An Exception occurred". So i did some googling and searching around and found out that JavaFX is not in the core Eclipse and so have to be handled differently. Also i found something which can be done via command line but this also didn't work for me (couldn't locate the path and other disturbing things).

So my question is, is there a simple way to export JavaFX project from Eclipse? I'm pretty confused about this topic and need some help.

charen
  • 371
  • 1
  • 7
  • 20

2 Answers2

3

If you correctly created the JavaFX project you will have a project structure like this:

enter image description here

Double click the build.fxbuild file, it will open an window with this option in the top-right corner:

enter image description here

Click generate antbuild.xml and run.

If the console shows BUILD SUCCESSFUL (and it should) its done.

The exported jar will be found at MySample\build\dist\

Math
  • 3,334
  • 4
  • 36
  • 51
  • Okay, did this and now it gives me an error: "Unable to find javac compiler". Did some searching on this aswell and found this thread: http://stackoverflow.com/questions/8400637/unable-to-find-a-javac-compiler The best answer is: Window > Preferences > Installed JREs and change the settings from JRE to JDK. I got there and there's jre7. How should i go on now, to change it to JDK? – charen May 09 '14 at 14:20
  • In this screen click add, and set JRE home `C:\Program Files\Java\jdk1.7.0_25` and JRE name `jdk1.7.0_25` as an example. Once added, check the `jdk1.7.0_25`, click OK and then try again. – Math May 09 '14 at 14:24
  • 1
    BUILD FAILED C:\Users\Kevin\Documents\UT\2013\kevad\OOP\Baila_2.0\build\build.xml:87: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:resources Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any / declarations have taken place. No types or tasks have been defined in this namespace yet I've set the Vendor name as Baila2, Application title as Baila and version as 1.0.0. Which other name is required here ? – charen May 09 '14 at 14:30
  • @charen I believe you have to setup the JAVA_HOME environment variable. Please see [here.](http://stackoverflow.com/q/11161248/1964435) – Math May 09 '14 at 14:36
  • Did the Environment variable thing in My Computer and set the directory C:\Files\Java\jdk\bin as shown in your link, but the namespace error is still active. I also did restart my eclipse. if i click on the error, it refers me to here: – charen May 09 '14 at 14:43
  • @charen `Build Directory` field has `${project}/build` or something? I'm starting to run out of ideas. Maybe see [here](https://groups.google.com/forum/#!msg/efxclipse/H-ZOVXtaK6g/qo8P6Iy-248J) a guy there have this exactly same error. – Math May 09 '14 at 14:47
  • It has indeed $(project)/build – charen May 09 '14 at 14:48
  • The link you provided had some ideas in it: Run->External Tools_>External Tools Configurations and selecting JRE Tab. I had to change the Execution environment from 1.7 to CDC-1.0/Foundation-1.0 (jdk1.7.0_25) (and CDC-1.1 also works). Now the build was successful. Although if i run my application i will get an exception, any ideas? – charen May 09 '14 at 14:54
  • Get exception by building the jar or by running the application? If is by running the application it's probably preferable to create a new topic, be sure to post the fullstacktrace (it is shown in the console), and the relevant part of your code. Also, if you debug it would be a great idea to add what you have seen while debugging. – Math May 09 '14 at 14:57
2

Thanks for Math, who helped me to find a solution to my issue above and issues which were related to this.

I'm answering my own question since there were some things google didn't even show me and maybe someone else later may find this useful.

My first question was answered by Math above.

My second question: how to resolve an issue - unable to find javac compiler, was also an easy one actually:

Window > Preferences > Installed JREs and change the settings from JRE to JDK For this, add JDK from Program Files/Java/java_vesion

My third question was about namespace issue: I was given an error:

BUILD FAILED C:\Users\Kevin\Documents\UT\2013\kevad\OOP\Baila_2.0\build\build.xml:87: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:resources Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any / declarations have taken place. No types or tasks have been defined in this namespace

It was resolved by changing Run->External Tools_>External Tools Configurations and selecting JRE Tab. I had to change the Execution environment from 1.7 to CDC-1.0/Foundation-1.0 (jdk1.7.0_25) (and CDC-1.1 also works).

charen
  • 371
  • 1
  • 7
  • 20