Building JavaFX 2.0 App on Mac, deploying on Windows - javafx-2

What are your strategies for building your JavaFX application on Mac and deploying on Windows ? I am currently having issues with how to bundle up my application so that it is double clickable on both platforms. I have tried using the ant-tools, but the jar file produced complain that JavaFX 2.1 needs to be installed on my Mac (how can I place the JavaFX 2.1 DP distribution so that the double-clickable Jar knows where to find it ?)
On the Windows side, Java7u3 is installed, which "comes with" Java FX 2.0.3. I need for the application to be able to execute as a double clickable JAR file here as well.
Any suggestions as to how this is set up ? I am using Maven to build my project. The more details you can provide the better.

Since 2.1 release the only (official) way to install JavaFX on Mac is cobundle installation with Java 7u4 (opposite to developers preview versions being published in zip archives).
If JavaFX on Mac was installed this way then jar with JavaFX can be run by double-click.
On Windows same jar by double-click will ask to install "JavaFX runtime" and will start if one is present already.
N.B.: in 2.2 release Mac/Linux would start to support jnlp (WebStart) run (already supported on Windows) which may suit you even better.

Related

jdk1.7's javac can't find javafx jar without -cp option

I've read several questions on this site and elsewhere that indicate that when Oracle JDK7 is installed, it should not be necessary to specify the classpath to jfxrt.jar when the JDK is installed correctly. Unfortunately, my installation does not seem to be correct, but I cannot figure out what is wrong.
I used the correct RPM for my Red Hat Enterprise Linux 6.2 Server and I'm able to build JavaFX apps in Eclipse when I added the jfxrt.jar to the External Jars. But when trying to compile and run from the command line, it does not find JavaFX classes unless I specify the -cp option to javac and java. The server was originally using openjdk-1.6, but I used alternatives to configure javac and java to point to the newly installed JDK. It looks like that is working fine, except for this issue.
I found that the same problem plagued me when trying to run the JavaFX Exporter. I was trying to export a project that runs fine in Eclipse. But it could not find the JavaFX classes when trying to run. And I haven't worked out how to tell the exporter where the jfxrt.jar file is located.
For reference, the jfxrt.jar is located at /usr/java/jdk1.7.0_21/jre/lib/jfxtr.jar on my system.
when Oracle JDK7 is installed, it should not be necessary to specify the classpath to jfxrt.jar when the JDK is installed correctly.
That is not true.
If you want to compile and run a JavaFX application in Java 7 (u21) and you are not using the JavaFX packaging tools, you need to add jfxrt.jar to your classpath.
See Compile code using JavaFX 2.0 (using command line) for samples of setting the JavaFX classpath for compiling (with javac) and running (with java) a JavaFX 2 application from the command line.
Some IDEs or IDE extensions are aware of this and will automatically add jfxrt.jar to your classpath (e.g. the e(fx)clipse plugin or the NetBeans JavaFX project type).
Some 3rd party tools such as the JavaFX Maven Plugin or the JavaFX Gradle Plugin also package JavaFX applications so that you don't need to add jfxrt.jar to your classpath.
For Eclipse development, use of the e(fx)clipse plugin is recommended, as it takes care of classpath issues (as well as providing other useful capabilities for JavaFX developers).
For Java 8, jfxrt.jar is on the default classpath, so you don't need to explicitly set your classpath to use JavaFX with tools like javac.exe or java.exe for that Java version.
OpenJdk7 does not include jfxrt.jar. Use Oracle Jdk7 instead will help.

How to embebed javafx 2.1 in an installation package

I need to distribute a javafx 2.1 application but the client doesn't want to be asked if he wants to install javafx 2.1. It should be automatically installed. Does someone know how to wrap it in a dmg and in an exe package??
Thank you very much in advance.
There is a tutorial here: http://fxexperience.com/2012/03/packaging-javafx-applications-as-native/
and there (although for 2.2): https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx
Finally I got it !!!!
I'm going to explain how I got it from my perspective. Sorry if it sounds a little bit dummy but I'm not used to build desktop applications and with a new technology as javafx is even more difficult for me.
Download the latest version of the jdk (in this case the 7.0 one).
Follow the steps from the tutorial and include your .jar and the jfxrt.jar
As a main class I set com.javafx.main.Main
Create the application and now, the most important part:
Once the application has been created, open it (right click on the app and "show package content". Go to the folder: Content/Resources/Java.
Do the same operation with the vm: go to /Java/JavaVirtualMachines and right click on the 1.7.0.jdk to open the Contents folder.
Copy ALL the .jar and .dylib from the jdk to the java resources in your application
Run the application and it will work :)

How to make a executable file of JavaFX 2.0 project?

I want to make a executable file of my project which I made in JavaFX 2.0. Can anyone help me with this?
The JavaFX team implemented support for this in the tools bundled with the JavaFX 2.2 SDK (included in Java7 from update 6). The JavaFX packaging toolset for packaging executables is documented in self-contained application section of the JavaFX deployment guide.
See RT-19446 "Add ability to co-bundle Java + JavaFX + App into a single native executable" for more information (anybody can sign up to view the jira).
3rd party tools such as the JavaFX maven plugin or the JavaFX gradle plugin, streamline integration of building native JavaFX executables using common build systems.
The JavaFX packaging tools can also be used to natively package any Java application, not just JavaFX applications. For example, a Swing application, as demonstrated by this shell script for packaging a Swing application using JavaFX on OS X.
If you want to do the packaging for the 2.0 or 2.1 versions of JavaFX (not JavaFX 2.2+), then you should review Packaging JavaFX Applications as Native Installers.
Javafx 2+ can now easily be packaged as a native exe (with an added payload, which the current JRE), the up to date (as in the end of 2012) article is here: http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm
Out of curiosity I created an executable on Windows (copy-pasting the netbeans build code into netbeans' build.xml) from the canvas and the hello world examples: the app is around 20k, the executable/launcher is around 80k and the added runtime is 138mb.
By the way if you have an older netbeans install (installed with a pre 1.7jdk) you may have to update it or edit its netbeans.conf fixing the "netbeans_jdkhome" path, otherwise the bundled executable's packaging may fail.
There are several tools to generate a customized exe launcher for your Java application.
I have good experience with Winrun4J: http://winrun4j.sourceforge.net/
but you will always need an installed Java/JavaFX Runtime even if you have an .exe that contains all your code.

windows application having no dependency to install

I want to implement windows desktop form application having no dependencies to install (e.g. framework, third-party etc).
In which technology I can achieve this?
Can i achieve this goal in C# Win-forms?
You can build an MFC app that requires no installation (just copying the files to the target computer) by statically linking and/or deploying the Visual C++ runtime redist side-by-side.
As Arnon has answered, you can build a .Net app that requires no installation if you target a version of .Net that is pre-installed on your target operating system. This blog entry lists the .Net versions included with each version of Windows.
what version of windows are you targeting your application to ? different versions of windows have different versions of .NET (see this link for details).
So basically, if you are looking for no installation you'd have to shoot for the lowest common denominator and/or ship multiple versions of your app.
I understand that it isn't what you want but -If you do go with .NET it is usually better to ensure that the installer will install the right version of .NET if needed (see this link for example)

Problems creating a Java Mobile Application project

I have installed the Netbeans 6.7 IDE with Java ME included, but cannot create a Mobile Application project from the Java ME category. When I select the project type the wizard stops at "Finding Feature" with the message:
Not all requested modules can be enabled:
[StandardModule:org.netbeans.modules.mobility.end2end.kig jarFile:C:\Program Files\NetBeans 6.7\mobility8\modules\org-netbeans-modules-mobility-end2end-kit.jar.
I am attempting to run this on Vista Home Premium. I have tried to run the IDE as Administrator with no luck.
I am at a loss for where to go next as I cannot seem to find any information regarding this issue. Even if you don't have the solution any insight into this error message would be helpful.
I am unable so far to get the project running via the Netbeans IDE install. I have, for the time being, installed the Java ME SDK which includes a very stripped down version of the Netbeans IDE for mobile development.
I originally had some issues starting the SDK as well on Vista. The IDE reported that it could not connect to the device manager on localhost. After some searching I found this link: Java ME SDK Startup Problem which suggests changing the hosts file localhost entry from IPv6 to IPv4. The fix worked perfectly and I can now compile and run code in the emulator.
This is not an optimal solution as the SDK does not include the visual design tools, however I am able to get a basic project going in the mean time.
I have given up on the 6.7 version and have instead located and installed 6.5.1. This previous version has been working just fine and seems to do everything I need.
I ran into the exact same error today while installing NB 6.8 beta. To resolve it we need to install two plugins:
Java Web Applications (as mentioned by Ali above) and
Sun Java System Web Server 7.0
Note that these two are part of the Category called "Java Web and EE" hence the confusion that we need to install Glassfish App Server. But we need these two plugins because they are required for debugging using breakpoints in emulator. Netbeans runs a web server when we do breakpoint based debugging.
Also note that the Java Web applications needs SOAP Web Services and JavaScript Debugger plugins to run and so these plugins are also installed when you try to install it.
You also need to install "Java Web Applications" plugin.
Tools->Plugins->Available Plugins
If the module is present, you should try unzipping it to check its content makes sense.
You should also be able to rebuild it from Netbeans sources.
You can also try to figure out why this happens by debugging the module loader inside Netbeans from its sources, using another IDE, presumably the latest version of Netbeans you can find without the issue.
If the module is missing, you might want to get the missing jar file from an installation of a previous version of Netbeans, see if it is compatible.
6.5.1 isn't missing any module.
back in version 5.5, the mobility module had to be downloaded and installed separately from the main IDE.
If you want to consider using Eclipse for developing your J2ME app...I've written a post related to that some time ago: here.

Resources