Deploying Java application to a Linux computer - java

I have developed a desktop Java application on Windows using Eclipse. It is just a console application. It uses several third party jar files and on Windows, several third party dll files are also required.
On the Windows machine, I can run the app from a command prompt as well, which I have copied from Eclipse. The command prompt references several of the third party jar files in the -classpath argument. In the development environment on Windows, all the dll files have been placed in the project home directory. The third party jar files have been included in the project Properties, "Java Build Path" setting on Eclipse.
Now, I want to move and run this app to a Linux computer for deployment. How should I do it? One way would be to use the same command line that is being used on the windows machine with modified -classpath arguments with the destination of third party jar files on the Linux machine. Is that the right approach? On the linux machine, I would also need the third party Linux native .so files. Should I just copy them to the project directory on the Linux machine? Should the project directory structure be same as the one I have on my Windows development machine?
Or should I just export (Eclipse Export) everything into a jar file and run the app using java -jar myapp command? Where should I place the third party jar files and native .so files in that case?
I have read a lot on this topic but still cant get any clarity on whats the best approach especially with third party .dll, .so and jar files involved.

Related

How to create .exe wrapper to install the Java application

Can any one please suggest me that how can I create .exe wrapper to install my Java application.
Currently Iam using the following command to install my application.
"java -jar application.jar"
After googling I came to know that we can create .exe by using some third party tool which is open source.
But don't know exactly which is best for my requirement. I have only application.jar with me as an input.
Thanks In Advance.
In order to make the command double-clickable, you have two options.
The first is a bat file with exactly that string "java -jar application.jar" in it, which is double-clickable just like exe.
The second is to make an exe by compiling the following C program.
int main(){
system("java -jar application.jar");
}
I like to use 7zsd.sfx to create installers for my java applications.
Directions:
1.) install 7zsd.sfx from http://7zsfx.info/en/ and install 7z
2.) create a .7z archive
3.) add all the jre files required to run the java application to the archive
4.) add the application itself to the archive
5.) add a .bat or .exe file (for windows) to install the files after 7zsd.sfx extracts all the files
6.) add a .bat or .exe file to run the java application using the jre files
7.) create a file (preferably named "app.tag") with a structure such as that below (add your own parameters)
;!#Install#!UTF-8!
Title="My App"
BeginPrompt="Do you want to install My App?"
Progress="yes"
ExtractDialogText="Please wait while app files are being extracted..."
GUIFlags="32"
ExtractTitle="Installation"
FinishMessage="My app has been installed and added to your desktop."
RunProgram="setup.bat"
;!#InstallEnd#!
The RunProgram is the program that runs after the files are extracted to a temporary folder. This program should create a permanent folder to hold the necessary extracted files (jre, java application, and executable to run app with jre). Additionally, the program should create a nice, good-looking shortcut for the executable file used to run the app and it should move it to the desktop and add an icon.
Finally, to create the exe which will install your files, go to the command line and access the folder with 7zsd.sfx and type in the following command:
copy /b 7zSD.sfx + [pathToDirectory]\app.tag + [pathToDirectory]\yourAppArchive.7z [pathToDirectory]myExeInstaller.exe

Java App installer and launcher for both Mac and Win?

I have a large Java app, with many required .jar files.
I'd like to build a native launcher and installer for it, to run it on both Mac and Win machines.
It looks like I can use Launch4J to create a .exe file launcher on Windows. (though it only wraps a single .jar, the others have to be available in the path.) Then use IzPack to create a runnable .jar file that will install the .exe and relevant .jar files into a directory.
How do I do the same for OS/X?
After more digging, and avoiding all the dead URL's I found, I've come up with:
A) Use Launch4J to build a .exe for Windows systems.
B) Use AppBundler (from java.com) to build a App Bundle for OS/X.
IzPack can be used to make an installer for either platform.

How do I make a final executable file for my Java program?

I created a tic-tac-toe game in Java. It runs fine on Eclipse.
How do I compile this file (which is currently a .java file) to the standard file format of Java applications, so it can be run from the desktop like a normal program?
What is the standard file type for the final executable Java application? What should be the file type if I want people to easily and without any computer knowledge run my program on their computers?
with eclipse right click on your project. then export it as a runnable .jar file.
Project Right Click > Export > Runnable .jar File.
First choose your project under "Launch configuration", then choose your destination.
After that click finish. Your program should be in your destination folder. Double click to start (just like an .exe file)
For example: If you export it to your desktop, and you name it "TicTacToe", the file on your desktop is "TicTacToe.jar" - ".jar" is your executable file
Done
You have to compile your java class first
javac TicTac.java
and then execute it
java TicTac
Note: that here you provide the name of the class with the main method!
As the other answers indicated, you can create an executable jar using eclipse (or a number of other tools). What these tools are doing under the hood is defining the Main-Class: attribute in the jar's manifest.
In Windows, your users can double click on an executable .jar to launch it, as long as the file associations are configured correctly. However this may not be obvious to windows users who are trained to expect some sort of .exe extension.
To solve this, you could use launch4j to wrap your executable jar in a windows executable. Note: this doesn't change your java application into a native application (it still requires the JVM, etc), it simply makes it launch more like a native application.
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.
Note that JWS is more effort for us to deploy (it involves not only Jarring and signing the code, but creating a JNLP launch file and a page on the net or network to check that Java is installed & serve the files to the user), but is super easy for the end user.
If there is a JWS deployment, the Jar does not have to be an 'executable Jar' as described in the other answers.
The command should be javac yourFile.java from you command prompt and then after compilation, class file is created. You can run it using java MailClassName
You can find a good tutorial on using javac and java commands here.

Java Application Build

We have a Java EE application which requires some jar files, a JVM and Tomcat.
How do I create a build through which a user can install and run my application in a non Java Windows environment?
The user won't need to install a JVM or Tomcat separately, but my build will configure a JVM and Tomcat for my application.
The Java installer creates a couple of registry entries but these are not necessary for it to run. So what you can do:
Ask for permission to package Java along with your code (the Java VM is copyrighted work, so you can't simply do what you want)
Install Java once and then simply add the new files on the hard disk to your installer
Unpack Tomcat and add those files as well
Copy your app into the tomcat/webapp/ folder
Write a script that packages and configures everything

How to convert jar files into exe & rpm

I have the following jar files for my app:
DesktopApplication1.jar
Plus , i have used the some extra API's for my app , like jsoup, jexcelapi etc. There are about 7 api's in the lib folder.
How to make a EXE file & RPM file out of all these jar files?
P.S. I am a first timer. So take that into consideration.also, I have used Netbeans 6.8. So the main API is in \dist folder. And the API used is in \dist\lib folder.
thanks in Advance
use jsmooth to make exe from jar
Build your JAR with fatJar to include all the dependencies in it, and then make it executable with your favorite tool (I use Launch4j)
RPM is little bit different, since it is not executable, but package format. There are lots of tutorials, how you build it up.
You could make a BAT file a file with .bat(For windows) extension
Just open notepad and write the following text
java -jar DesktopApplication1.jar
Save the file as filename.bat(the .bat extension is important)
Place the .jar and .bat files together and just double click the .bat file every time you need to run the jar...
If you don't want to keep both together then give the absolute path of the jar in the .bat file
java -jar AbsolutePath/DesktopApplication1.jar
For a linux machine make a file with (.sh) extension rest of the procedure is same...
Try InstallJammer. It provides what you want.
Deploy the app. with Java Web Start. JWS Can make it easy to add other Jars to the apps. run-time class-path, avoiding the common problem with fat jar of violating the API's distribution license (when it says WTE 'you are allowed to distribute this in unaltered form..') and can provide the further benefit of only downloading the parts that the user requires (when the user requires them).
JWS has many other cool features like desktop integration (menu bars, start menu item), splash screens, automatic updates, support by the owners of Java, and compatibility with any platform for which Java is available.
For creating .exe to run on Windows:
Download launch4j from http://launch4j.sourceforge.net.
build wrapper .exe through launch4j.
Download innoSetup from http://www.jrsoftware.org/isdl.php.
Build .exe as installer, the setup file, for user to download and install.
Install rpm for linux:
If your application used other native libraries, you need to download and install Linux native libraries. This is how we build rpm for our app.

Categories

Resources