I managed to embed JavaFX HTMLEditor inside a Swing desktop application using this this tutorial, locally in Eclipse all works great.
My question is how to deploy this to our customers? Oracle have a tutorial for WebStart and Applet deployment but I see no information for desktop apps.
Currently I copy libs and binaries from my installed JavaFX SDK into my project and include them when I compile distribution:
/my/application/lib/javafx/lib/javafxrt.jar
/my/application/lib/javafx/bin/[dll:s from JavaFX Runtime]
But this seems very odd, there must be a better way? I need some help here. The thing is that during development in Eclipse I need javafxrt.jar on the classpath, so I've copied the jar file because I couldn't see any environment variable like javafx_home I could use. But when JavaFX is loaded it tries to load the dlls: from a relative path, that's why I also copied the dlls into my project.
This is problematic for deployment, I rather not ship 32 bits JavaFX Runtime if clients have a 64 bits JVM installed (that won't work I think). Currently our customers only run Windows so for the moment that's not a problem.
Isn't there a way in runtime to check if JavaFX is installed or not, and if so get path to it "dynamically"? Shipping the jar file is no problem, but I'm worried about the platform dependent binaries.
Update: WebStart is not an option because we bundle/install the application with an old Windows app that is the predecessor, not all functionality is ported yet so the two applications communicate with a custom made IPC protocol.
Any help is appreciated!
Thanks in advance.
Use Java Web Start to deploy the app. JWS makes it simple to add dependent Jars & natives to the run-time class-path of an application, and can partition the download of natives by platform.
In fact, I'd be surprised if the JavaFX API does not already offer an extension JNLP that client apps. can simply link to in their own JNLP launch file.
Use the new JavaFX ant tasks described here. Worked fine for me.
EDIT: Also see native packaging: https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx
You can embed a JavaFX component in java swing application using JFXPanel (javafx.embed.swing.JFXPanel).
it is used to embedded JavaFX components in the java swing application.
learn more about JFXPanel at
https://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/JFXPanel.html
Related
I've recently started learning SWT (on class #4, to be precise) due to business requirements, and previously I had been developing with Swing for 2 years.
We deployed Swing applications as jars with resource dependencies. In SWT, what are the deployable forms and equivalents?
I have questions but since my training is online, I'm on a course-ware and there is no instructor, except StackOverflow:
Can SWT apps be deployed as independent EXE's? And what's with the "Eclipse EXE" thing people talk about? Does it mean that all SWT outputs will be Eclipse based EXEs? Or can they be completely independent EXEs?
If the answer to 1 is yes, how does the compiler produce native win32 executable code? This is one area where I'm thoroughly confused. Typically, a deployable jar is fed to the VM which reads the manifest and does its stuff, but an EXE as output? What's really behind the scenes?
How are external resource bundles managed? At the time of deployment?
Internationalization support?
Thanks.
Deploying an SWT application is exactly like deploying a Swing app, with the addition of several jars and a native library. You must currently be using some tool to make exe files for your Swing app; that tool may or may not be competent to also package up a native code library. It is unlikely that the tool is creating 'native win32 executable code'. Rather, it is packaging up Java class files along with the JRE and a stub Windows PE file.
SWT is developed as part of Eclipse. Eclipse has the Rich Client Platform, or RCP. If you build your Java application as an RCP application, you can use the Eclipse tools to generate an executable package for Windows (or anywhere else). It is not a single executable, it's a directory with an executable in it. However, you don't have to use Eclipse to use SWT.
An RCP application has to use much more than just SWT. It has to be constructed as a set of OSGi bundles that depend on the core Eclipse platform. Once you have such a thing running inside Eclipse, there is a wizard in Eclipse that will create a Windows 'executable' (a directory containing your code in JAR file(s), a lot of Eclipse code in JAR files, the JRE, and a PE .exe stub). You can automate that process from ant, though I've never done it myself. You will need to do book-length reading to get up to speed on all of this, I fear.
There no difference between SWT and Swing in terms of resources and internationalization. Other Eclipse-related libraries include an I18N discipline, but not the core SWT. You just use locales and property files as in any other Java application.
SWT is not Eclipse-based, but the Eclipse UI is SWT-based. Eclipse uses the SWT library for its drawing. It is used a GUI library from the Eclipse consortium, available for many systems. If you want to deploy your normal Java Application with an SWT GUI you just add the corresponding libs and .dll's or .so's. Therefore, everything you can do (deployment) with Java respectively speaking Swing, can be done with SWT, if you provide the according libraries. There are tools and ways to compile everything into .exe's but that is not necessarily needed.
I do not really get the Eclipse EXE thing you are talking about, but eclipse just provides a starter exe, which is basically just a wrapper. Otherwise, some people refer to Eclipse RCP als Eclipse EXE but this is not correct. You CAN use the Eclipse RCP to base your App and this would use SWT as UI library. But you can use SWT all by yourself just as library without the Eclipse trail.
I hope this helps.
You can use a java to EXE wrapper like this one http://jsmooth.sourceforge.net/.
Hope it helps.
Basically you need to get your project running with the conventional java -jar command.
Then create an exe bootstrap program that runs the command when you double click it.
Extra things can be done like checking JVM versions inside the exe program.
I am developing one desktop application in javaFX. I am using in memory database hsqldb. I want to make this application to run on any windows machine by just double click or by installing.
I have gone through the launch4j library, using which I can make .exe file of my jar.
But if I create the .exe file, then I can open this application by just double clicking on it. anyone can copy and paste and open it.
I am confused with install word here.
What extra things will happens, if I want to make my application installable. Because I want to give an expiry date my application.
The answer to your question lies on the description of launch4j on their site.
The executable can be configured to search for a certain JRE version
or use a bundled one, and it's possible to set runtime options, like
the initial/max heap size
Not every machine you distribute the jar to may have a JRE. A bundled JRE will help the launcher run your jar if a JRE cannot be found on the target machine.
If you want to force updates on your jar, consider running a plugin mechanism or forcing the user to download a new version. It sounds to me like a web application might suffice instead ?
I created a small swing application having some GUI components and some java code. When I run it from the IDE, I see GUI open and it works as expected. Now I want to distribute this application to others and it will be run on different machines. I am just wondering as how could I distribute it?
Under project folder, I see following -
-dist
--lib
----some required jar files
--project.jar
-build
--classes
----packagename folder -->UI classes
----projectnamefolder--->projectname.class
--empty
--generated-sources
I am using Windows 7 64 bit with jdk 1.7. Earlier I was able to distribute such apps and they worked from command line or by double clicking .jar file.
Is there anything different in case of swing apps? Kindly suggest.
If I run from command prompt the jar file located under dist folder, it doesn't throw any error but no GUI appears.
Follow these Steps in LINK and other system will need JRE to run.
I think you are missing swing-layout-1.0.jar
To add the Swing Layout Extensions library:
Right-click the project's Libraries node and choose Add Library.
In the Add Library dialog box, select Swing Extensions Layout and click Add Library.
Click OK to close the Project Properties dialog box.
Additional to doing what Shiv suggested, I followed link , and it clicked to me as what was i doing wrong.
Now I want to distribute this application to others and it will be run on different machines. I am just wondering as how could I distribute it?
For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.
..sounds cool, would search some tutorials as to see how to use it
The info. page at SO linked above includes the collected knowledge of the SO poster who has the most up-votes for JWS ( me ;) ). It also includes a list of links to tutorials and other information.
I want to use QT Jambi for GUI (Java project). The GUI needs to have animations (similar to Iphone apps). That is why, I do not want to use Java Swing.
My question is, after I develop the application, is there any automatic mechanism which would create a setup file which could be used to install my application in any computer (may be separate "setup" files for separate OS). In other words, I would like my users to download just one file: setup.exe. This should install the app in their computer.
I know there is one such app for .jar files (I forgot the name). But QT is a C++ library and I do not like bothering the users, asking them to download QT just to use my app.
I presume you are tagetting win32 only on the desktop and looking for free/open tools. With no response to this questio so far I thought I'd provide some info towards this point even if it is not the answer you really want.
I have been looking over the QtJambi ecosphere for the past couple of years and I'm not aware of such a tool to provide you with a process to follow that results in an EXE. There are all kinds of caveats.
The task:
Ensure the JRE5+ is installed on target system.
Ensure QtJambi files and perform things like extraction of native JAR.
Ensure QtJambi pre-reqs are installed on the target system (such as MSVCxxxx runtimes).
Finally install your application and fixup the startup configuration to make use of information above.
Setup desktop fo reasy access (Program Group, Desktop Icon, Menu items, Shortcuts)
You will find that NSIS http://nsis.sourceforge.net/ can be a tool to get some parts of the process and maybe provide a framework to write modules for NSIS that do other parts of the work. But I have found NSIS somewhat lacking when you step outside of a simple unzip of data and setup of desktop install process.
Another solution for you would be to simply provide everything that works in one ZIP file, this would include a copy of the Java JRE embedded, a copy of QtJambi embedded, the rest of your JAR and then write a toplevel *.BAT file to setup %PATH% and other arguments to run your supplied java.exe against your application. Obviously now the JRE is not likely to get updated so at some point will be considered insecure.
NSIS isn't the only such windows installer that exist.
Maybe there is a fully automatic one click install wrapper with custom parts to help setting up QtJambi, but I doubt it at this time.
Good question, and one good attempt at an answer.
I've gone down a slightly different route: embed the Qt Jambi libraries, but not a JRE. I have some basic sh/bat launch scripts which configure the resources required and am using IzPack for the installer (though NSIS might be a good alternative).
Problem: how to find the JRE
Solution: the IzPack installer needs a JRE to run, so guarantees the availability of one. It can update a variable in scripts during installation.
Solution (Windows): use the registry
Last resort: use the path
The ideal would be to integrate all three into a batch file. Anyone done this?
Problem: Qt & Qt Jambi libraries
Solution: distribute with your application and link from the shell/batch file.
The problem with this is how to make sure your libraries get used when binary-incompatible Qt libraries are already installed on the system. On Linux, extracting the libraries and exporting LD_LIBRARY_PATH seems to work. On Windows I haven't solved this and on the Mac I haven't tried.
Problem: most appropriate Qt libraries
32-bit Qt libraries probably won't work with a 64-bit JRE; this is a problem I haven't yet had to deal with. Probably the best solution would be to include both 32-bit and 64-bit Qt libraries and select between them from a script at run-time (or possibly install-time).
Another issue is related to themes: Qt has support for using native themes, but only from the platforms it's compiled on. Thus, compiling Qt on an old Windows version and using the libraries on a modern version of Windows seems to work but results in ugly Windows-98-esque widgets. The easiest solution seems to be to launch with -style Plastique (or cleanlooks) to get nicer-looking widgets.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Export JAR with Netbeans
I have created a NetBeans Project and now I want to create a package from the project. As this is my first project in NetBeans. Can any one help me to create a package from my project for distribution?
Expanding on the question for the .exe:
I have good experience using Winrun4J to generate an exe launcher for my Java applications. It's quite forward to setup and generate and it supports 32 and 64 bit Windows.
You can even put all needed jars into the exe.
http://winrun4j.sourceforge.net/
But (as you seem to be new to Java): the exe is only a wrapper. It still requires a Java Runtime to be installed on the system where you start the exe!
If you have several project in development environment, make sure you have set the project you want to distribute as a main project. It can be done via mouse right click menu on project name in the left pane.
Click on menu: "Run -> Clean and build main project"
Inspect your project folder, find folder dist in your project folder. There is *.jar file. It is packaged compiled project file.
If you want to code desktop apps. that will run on Windows, OS X & *nix, write them in Java & deploy them from a link using Java Web Start.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
I high-lit the part that is relevant to your next comment.
can I give my own icon image to the executable file?
Why should the user ever see a .jar (or a .exe for that matter)? JWS offers desptop integration, which might consist of a desktop shortcut and/or menu item on supported OS'. Either of those can have an image (within limitations) as supplied by you.
The deployJava.js script checks the user has the required minimum version (helps them to install it, if not), before running an applet or providing a link to a JWS app.