Dynamically loading jar file into Java program - java

I'm working on Desktop applications. I'm using JFC/Swing to build the application.
Now I want to build application that can be upgradable by changing some jar files, instead of installing entire application again.
I'm stuck with some basic steps. I want to add JMenu from various jar files, so I dynamically added those jar files. Now my issue is that, I want to perform some functions like adding JInternalFrame to the main class, which loads entire jar files. I am not able to achieve it.
Please help me with this issue, and suggest any idea to make it possible.

Now i want to build application that can be upgradable by changing some jar files, instead of installing entire application again.
Java Web Start..
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
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..

you can do it easily using URLClassLoader, you can see s simple example here:
http://snippets.dzone.com/posts/show/3574

Related

Deploying Java projects to other users

I am new to Java and is using Eclipse.
Whenever I have build a Java (JFrame) project successfully on my PC and when I deploy the java project files to other users, I have to compile the projects on other ppl's PC before they can really use it.
Is there any convenient way to tackle this? i.e. When I placed those Java files to a shared folder, all other users (new/existing) can execute it on their PC.. (juz like .exe in MS Window) Actually how is the practice outside?
The best way to distribute a desktop app. to users is Java Web Start. It requires some extra work from us the developer, but is a breeze for the end user.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
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..
You can use Eclipse to create a JAR file for your project, and it will generate an executable JAR that the others can run. For more on creating JARs in Eclipse, see this.

Converting Java Desktop Application to Web using Applet or Java Web Start

I know that I can convert a Swing application to an Applet or a Java Web Start application. Is it possible to do the same with an application that's not Swing, say Qt using Java?
What I'm really looking for is a UI framework using Java that's as cross-platform as possible and also has a rich set of UI functionality. Being able to run the application as either a desktop or a Web application would be preferable.
What I'm really looking for is a UI framework using Java that's as cross-platform as possible and also has a rich set of UI functionality.
Assuming a desktop deployment, the three major frameworks are Swing, SWT and JavaFX.
Try the JavaFX Ensemble sample to see if that technology would suit your needs.
I know that I can convert a Swing application to an Applet or a Java Web Start application. Is it possible to do the same with an application that's not Swing, say Qt using Java?
QT is native code that doesn't run on the JVM - it is not a Java UI framework. Applet and Web Start programs require a Java class as their entry point. Any use of QT is such a scenario would require a Java <=> QT adaption layer and I am not aware of the existence of any such thing - you would probably need to build it yourself based on a technology like JNI.
Being able to run the application as either a desktop or a Web application would be preferable.
See the JavaFX deployment guide for various JavaFX deployment options and the Swing deployment guide for various Swing deployment options.
The definition of Web application is pretty nebulous. Here are some distinct scenarios:
You are restricted to just html5 => produce the html on a server to
distribute to the client.
You want html launching a Java
application => then something like WebStart in combination with the
Java Deployment Toolkit can be used.
You will be rendering a
JavaFX application inside a browser window => then use a browser embedded app.
There are many pitfalls for embedding java applications is web pages (just use google to discover some of them).
What I have done in one of my projects is develop the application as a web application and then generate a installable to distribute my application. This has great benefits:
It can be installed in a server and publicly available. Just as a normal web application.
It can also be installed in a desktop.
I used "Jetty" to embed the web server in my application and be able to run the application as a stand alone in desktop environment. The slogan of Jetty is "Don't deploy your application in Jetty, deploy Jetty in your application."
Also I used "IzPak" to package my application in a executable JAR for installation. If you want to make that JAR easy to install for people who might not have installed Java you can use launch4j which is a tool that wraps the JAR into an EXE. So it can validate first if the computer has already Java and if not inform the user that he needs to have Java installed to proceed. The only drawback of this is that if you wrap your application in an EXE you are limiting the portability to other platforms, but that's your decision according to the requirements.
Java Web Start apps can contain native libraries, so yes you should be able to convert an app using Qt (assuming the bindings exist) to a JWS app.
Applets on the other hand are tricky to make work with anything other than AWT/Swing, since you have no control over the creation of the top-level window.
If you want to use Qt you would first have to make Qt bindings for Java as they are not currently functional.
If you want to use Qt bindings from a Java Applet you will need to make your bindings an installable extension which would be a potential security risk unless you know what you are doing. You would also have to get the user to install your extension. Also IcedTea-web which are the FOSS plugin shipping with Linux will not load an extension. So if you want your extension to work on Linux you will have to fork IcedTea-web and make your own plugin.
So the short answer: Stick to Swing.

Runnable jar or bat file for executing java Desktop applications

As I know there are two standard ways you can distribute a Java desktop application:
Through a runnable jar file
Through a bat file which calls a jar file to begin execution
I want to know what is the best way among these methods and what are the relative advantages and disadvantages?
The list is missing the best one!
..
..
Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
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..
In case it is not clear, I vote JWS as the 'best' from a user point of view. The details of the advantages are pretty much expressed in the 2nd paragraph of the description, but also the last sentence of the first. Not to forget the 1st sentence of the next paragraph..
By default, an applet-like security sand-box is applied to code launched using JWS. ..
I think runnable jar would be a good option for desktop application. As I am using it for my desktop application is more comfortable and user friendly.
I think it will depend on who are the users of your application.
If the users are non-tech people you better go with a runnable jar because
they are less likely to pass an argument to your program.
In case they are your team members or other tech people, you may give them a .bat
to play around with your app.
For Windows, wrappers like Launch4j could be considered.
The open source software always use .bat or .sh file to distribute a java application.I think this way would be a good option.

How to create a setup file for a project that was written in netbeans?

I have created a GUI application using Netbeans and it has a connection to a database( localhost).
Now I want to be able to distribute it as software.
Is there any way to produce a setup file for the Netbeans project? and how can I distribute a Netbeans project which uses a MySQL database?
how can I distribute a Netbeans project which uses a MySQL database?
You might want to get familiar with NSIS. NSIS will enable you to automate the installation process.
Your installation process will have to do the following:
Check that the Java Runtime Environment is the same version you used or higher.
Install your application JAR file somewhere.
Install the MySQL version that your application requires
Create and initialize the tables for your application.
Your installation process can do the following:
Create an uninstall executable.
Add an icon so that the user can start your application.
This installation process will take some time to develop and test.
You probably want to use an installer. Have a look at:
Install4j
Installshield (commercial)
Advanced installer if you target only windows platforms
There are many others but I hope this can help you...
Use the solution made by the suppliers of Java - Java Web Start.
The deployJava.js (described in the linked page) ensures the user has the minimum JRE needed to launch the app. & MySQL.
Launch the app. using Java Web Start.
Reference an installer-desc extension for installing the DB. Store any set-up details into the PersistenceService for later use.
JWS works on all major platforms for which J2SE is available and also 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..

Installer for Java Desktop Application

I am developing an inventory system i-e a java desktop application. I am using Ms Access as database engine and there are certain modules e.g one makes reports using ireport and other such dependencies. I need to ask how can I make installer for my application which will install few fonts, copy database files, install jre to make it run etc. Please guide me in it.
Thanks in anticipation.
This is something I've briefly used in the past, and it may serve your needs. It's an open source installer builder system, tailored towards Java apps.
http://izpack.org/
I've used jsmooth which creates a single EXE-file that unpacks and run transparently. Not a full installer but worked well for us.
Note: I have not seen any Java installers which asks the "There is an update available. Update now?" question.
If this is important to you, then consider Java WebStart which checks for updates at each launch (but do not ask).

Categories

Resources