i have developed an application in java for linux i need to install it in linux in my system(ubuntu 10.04) and how to make executable for linux .i have the application as jar file
This and this.
echo "java -jar filename.jar" > runme.sh && chmod +x runme.sh
./runme.sh
You can create a simple shell script that run the following command:
java -jar mylib.jar
and then run the script using ./myscript.sh
If you're targeting a different machine from the one you've developed on, you'll need to package your JAR into a .deb file and either include a JRE/JDK in the distribution, or else declare a dependency on one of the apt packaged Java distros so that apt-get installs Java at the same time as your application.
For Java applications with a GUI, look into Java Web Start.
I never had much luck getting menu items to work on Ubuntu Linux, but desktop shortcuts were no problem. Maybe you can specify the exact sub-menu that the menu item is to appear under, and it will work.
JWS also works for Windows and Mac.
Follow this article and you need to create a file with gedit and name it with your package name.(e.g totem for totem media player listed in Applications Sound & Video) then in that file enter these lines and save to Input directory (mentioned in the above tutorial)
?package(yourpackagename):needs="X11" \
section="Applications/Sound" \
title="yourpackagename" \
command="/usr/bin/yourpackagename" \
icon="/usr/share/pixmaps/yourpackageicon"
enter your package name accordingly. Icon line is optional you can omit it. then
debian/input/yourpackagename /usr/share/menu/yourpackagename
add this line to install file
there we are adding the above created file into /usr/share/menu dir
Related
I want to convert a .jar to an .exe for microsoft. Is there any program converter for this?
Also if there's one for Mac and Linux I would appreciate suggestions for those too.
Launch4j works on both Windows and Linux/Mac. But if you're running Linux/Mac, there is a way to embed your jar into a shell script that performs the autolaunch for you, so you have only one runnable file:
exestub.sh:
#!/bin/sh
MYSELF=`which "$0" 2>/dev/null`
[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
JAVA_OPT=""
PROG_OPT=""
# Parse options to determine which ones are for Java and which ones are for the Program
while [ $# -gt 0 ] ; do
case $1 in
-Xm*) JAVA_OPT="$JAVA_OPT $1" ;;
-D*) JAVA_OPT="$JAVA_OPT $1" ;;
*) PROG_OPT="$PROG_OPT $1" ;;
esac
shift
done
exec java $JAVA_OPT -jar $MYSELF $PROG_OPT
Then you create your runnable file from your jar:
$ cat exestub.sh myrunnablejar.jar > myrunnable
$ chmod +x myrunnable
It works the same way launch4j works: because a jar has a zip format, which header is located at the end of the file. You can have any header you want (either binary executable or, like here, shell script) and run java -jar <myexe>, as <myexe> is a valid zip/jar file.
JSmooth .exe wrapper
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your Java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a website.
JSmooth provides a variety of wrappers for your java application, each of them having their own behavior: Choose your flavor!
Download: http://jsmooth.sourceforge.net/
JarToExe 1.8
Jar2Exe is a tool to convert jar files into exe files.
Following are the main features as describe on their website:
Can generate “Console”, “Windows GUI”, “Windows Service” three types of .exe files.
Generated .exe files can add program icons and version information.
Generated .exe files can encrypt and protect java programs, no temporary files will be generated when the program runs.
Generated .exe files provide system tray icon support.
Generated .exe files provide record system event log support.
Generated windows service .exe files are able to install/uninstall itself, and support service pause/continue.
New release of x64 version, can create 64 bits executives. (May 18,
2008)
Both wizard mode and command line mode supported. (May 18, 2008)
Download: http://www.brothersoft.com/jartoexe-75019.html
Executor
Package your Java application as a jar, and Executor will turn the jar into a Windows .exe file, indistinguishable from a native application. Simply double-clicking the .exe file will invoke the Java Runtime Environment and launch your application.
If your program is "publicly available non-commercial in nature" and has "a publicly available Web site that meets the basic quality standards", then you can try and get a free license of Excelsior. If its not then it's expensive, but still a viable option.
Program: https://www.excelsiorjet.com
As a side note: Here's a study of all existing Jar to EXE programs, which is a bit depressing - https://www.excelsior-usa.com/articles/java-to-exe.html
Despite this being against the general SO policy on these matters, this seems to be what the OP genuinely wants:
http://www.google.com/search?btnG=1&pws=0&q=java+executable+wrapper
If you'd like, you could also try creating the appropriate batch or script file containing the single line:
java -jar MyJar.jar
Or in many cases on windows just double clicking the executable jar.
I used Launch4J and it works flawlessy,
First, Go to your jdk and copy the bin and lib folder
Then create a folder for your app and make a folder called jre-(version),
Then paste these inside
Then open launch4j Put the exe file's path (Inside the app's folder)
Then go the jre option and inside bundled paths type jre-(version)
Then in minimun version type the version of the java you coded it in.
Then in the jre option put "Only use private jdk runtimes"
Then hit the gear icon. It will open a file chooser.
Choose your application's folder, done
Now open the exe file generated. It should work.
In case it does not, try the test run button (The green play one). If it says LinkageError in the console below, then in the jvm-options type --enable-preview. It should work.
I hope it helped.
For Windows, you can convert jar to exe using following ways:
Using Netbeans
https://erainnovator.com/convert-jar-to-exe-file/
Using Excelsior JET
https://youtu.be/iQSfUb8chjg
if you need to convert from .jar to .exe from java 14 you can used jpackage
jpackage is a command-line tool to create native installers and
packages for Java applications.
this article will help you
I want to create a windows installer for my jar file. I don't want to have to install jre/jdk on the target computer I want to deploy to.
I tried out jpackage (part of Java 14) and it didn't work for me. I tried the following command:
jpackage --input target/ --name my_pkg --main-jar NtbnsProj.jar --main-class myJFrame --type exe --java-options '--enable-preview'
It generates a my_pkg-1.0.exe, but I can't get it to run.
At this point, I'm willing to try even third party tools. I've tried install4j with no success. Another website I found said to use install4j with Inno Setup Compiler. This was more complicated and didn't work either. I thought maybe WiX Toolset might work.
If someone could provide step by step instructions, especially if the solution involves install4j, as there are many different steps where you can miss something. I was using a newer version of install4j, and it didn't match the online tutorials and videos. The menu selections have changed significantly. Perhaps I need to use an older version of install4j.
See my related article: How do I package a java jar file to run on a Mac without JRE installed?
Double check that your app runs directly then fix any issues before continuing:
java -cp NtbnsProj.jar myJFrame
It looks as though jpackage has worked, and generated your installer my_pkg-1.0.exe. When you run my_pkg-1.0.exe check that you have this file, then run it:
C:\Program Files\my_pkg\my_pkg.exe
If that fails, re-run jpackage with extra arguments --win-console --app-version 1.1, this will generate my_pkg-1.1.exe with console enabled. Re-install and running C:\Program Files\my_pkg\my_pkg.exe might report a useful error message indicating what is your real issue.
If you don't upgrade the --app-version each time, Windows will NOT update the existing release 1.0, or you must un-install before re-applying a re-build of same version my_pkg-1.0.exe. It just runs and stops without warning you.
See this post on how to set app-ver automatically.
I got it to work! #DuncG was very helpful with answering my question. I had a bunch of extra files in the directory where the jar file was, so I just created a new directory and only put NtbnsProj.jar in it. I then ran the following command: jpackage --name Test --input . --main-jar NtbnsProj.jar
I have a number of jar-files, some resources, h2 database, etc. in my project. To create Mac application I used Platypus. To run my application shell script was used.
However at this case when application starts then separate java process starts and there neither proper name of the app nor proper About description in Mac menu. Also Terminal starts that is not wanted.
How I should launch the app to avoid this drawbacks so that the name of the app and About description were the right ones?
What I see now (name and About):
My launching shell script is the following:
#!/bin/bash
export IRULE_HOME="$(cd "$(dirname "$0")" && pwd -P)"
export IRULE_LANG=en
export IRULE_REGION=EN
export IRULE_XMS=-Xms256m
export IRULE_XMX=-Xmx1024m
export LOG4J_CONFIGURATION=${IRULE_HOME}/conf/log4j2.xml
export JAVA_HOME="${IRULE_HOME}/jre/Contents/Home"
export DEFAULT_JVM_OPTS="$IRULE_XMS \
$IRULE_XMX \
-Dlog4j.configuration=file:"${LOG4J_CONFIGURATION}" \
-Dirule.home=${IRULE_HOME} \
-Dirule.client.logs.path=${IRULE_HOME}/logs \
-Duser.language="${IRULE_LANG}" \
-Duser.region="${IRULE_REGION}" \
$JAVA_OPTS"
export PATH=${JAVA_HOME}/bin:${JAVA_HOME}:${PATH}
export CLASSPATH=${IRULE_HOME}/lib/*:${IRULE_HOME}/conf:${JAVA_HOME}/lib/jfxrt.jar;
exec ${JAVA_HOME}/bin/java -Xdock:name="iRule Reader" -Xdock:icon=${IRULE_HOME}/image/irule.png ${DEFAULT_JVM_OPTS} -classpath "${CLASSPATH}" com.spi2.Main $*
How I created the app by Platypus. The process is simple: I set my shell-script and add all my resources. Also I can set up the icon. And I add Credits.html to allow About description as said in documentation:
You could try running the Java apps/processes in headless mode.
Try adding this option to your DEFAULT_JVM_OPTS:
-Djava.awt.headless=true
But since your Java app has a GUI, that may not be a viable option.
You could also try implementing your own handlers for the system menu using the com.apple.eawt Apple Extensions classes (ex. AboutHandler, QuitHandler, etc.), as stated in their Java Development Guide for Mac docs:
The next step to customizing your application menu is to have your own
handling code called when certain items in the application menu are
chosen. Apple provides functionality for this in the com.apple.eawt.*
Java classes. The Application and ApplicationAdaptor classes provide a
way to handle the Preferences, About, and Quit items.
I could not find the actual API docs though.
Here are some other SO links which may help:
What's the alternative to using the now deprecated com.apple.eawt.ApplicationAdapter in Java Swing apps on the Mac?
Can Java 7 use Apple Java Extensions?
How to get Apple Java Extensions (com.apple.eawt) work on JDK 7 and higher?
I developed a project using Java and now I've to deliver it to client who is using Linux. Which executable file format will be delivered and how to make that?
Executable file format?
If you're delivering a Java app, give them a jar file (and associated libs).
Provide a shell script to set up its environment and execute it.
For example, assuming I define ROOT_DIR as my app's install directory, and so on:
CLASSPATH="${ADD_JARS}:${CLASSPATH}:${ROOT_DIR}/lib/myApp.jar:\
${ROOT_DIR}/lib/jibx/jibx-run.jar:\
${ROOT_DIR}/lib/jibx/xpp3.jar:\
${ROOT_DIR}/lib/bindings.jar:\
${ROOT_DIR}/lib/commons-lang-2.0.jar:\
${ROOT_DIR}/lib/forms-1.0.5.jar"
"${JAVACMD}" -Xmx256M -DanyDefsNeeded=foobar -Dbase.dir="${ROOT_DIR}" -cp "${CLASSPATH}" myApp.main.Launcher "$#"
What goes into the shell script depends totally on what your app actually needs to start up.
A jar. If it is not executable, then a script (.sh) to launch the jar.
Well basically what you wanna put in a .sh file is the commands you'd normally type at the console to run your jar file. They should be separated by a new line (i.e. each on a separate line in the .sh file).
The most basic you can go is add something like this to your sh file:
java -Xms=64m -Xmx=256m -jar myJar.jar -classpath [dependencies dir]/dep1.jar,[dependencies dir]/dep2.jar
beyond this you can do more exotic stuff, like parametrise some environment variables, get command line argumens from when the .sh is launched and pass them to the jar executatble etc. Look up "bash scripting" for advanced stuff:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-2.html#ss2.1
You might have better luck using Launch4J, IzPack or other installer that has cross-platform capabilities. This might be a better first option than trying to understand the intricacies and idiosyncrasies of the different Linux distributions and shells.
If your app. has a GUI, the best user experience for installation/deployment can be had by way of Java Web Start. Note that JWS can deploy apps. to Windows, *nix and Mac. and avoids all the maintenance woes of generating 3 separate (platform specific) executables.
I want to convert a .jar to an .exe for microsoft. Is there any program converter for this?
Also if there's one for Mac and Linux I would appreciate suggestions for those too.
Launch4j works on both Windows and Linux/Mac. But if you're running Linux/Mac, there is a way to embed your jar into a shell script that performs the autolaunch for you, so you have only one runnable file:
exestub.sh:
#!/bin/sh
MYSELF=`which "$0" 2>/dev/null`
[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
JAVA_OPT=""
PROG_OPT=""
# Parse options to determine which ones are for Java and which ones are for the Program
while [ $# -gt 0 ] ; do
case $1 in
-Xm*) JAVA_OPT="$JAVA_OPT $1" ;;
-D*) JAVA_OPT="$JAVA_OPT $1" ;;
*) PROG_OPT="$PROG_OPT $1" ;;
esac
shift
done
exec java $JAVA_OPT -jar $MYSELF $PROG_OPT
Then you create your runnable file from your jar:
$ cat exestub.sh myrunnablejar.jar > myrunnable
$ chmod +x myrunnable
It works the same way launch4j works: because a jar has a zip format, which header is located at the end of the file. You can have any header you want (either binary executable or, like here, shell script) and run java -jar <myexe>, as <myexe> is a valid zip/jar file.
JSmooth .exe wrapper
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your Java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a website.
JSmooth provides a variety of wrappers for your java application, each of them having their own behavior: Choose your flavor!
Download: http://jsmooth.sourceforge.net/
JarToExe 1.8
Jar2Exe is a tool to convert jar files into exe files.
Following are the main features as describe on their website:
Can generate “Console”, “Windows GUI”, “Windows Service” three types of .exe files.
Generated .exe files can add program icons and version information.
Generated .exe files can encrypt and protect java programs, no temporary files will be generated when the program runs.
Generated .exe files provide system tray icon support.
Generated .exe files provide record system event log support.
Generated windows service .exe files are able to install/uninstall itself, and support service pause/continue.
New release of x64 version, can create 64 bits executives. (May 18,
2008)
Both wizard mode and command line mode supported. (May 18, 2008)
Download: http://www.brothersoft.com/jartoexe-75019.html
Executor
Package your Java application as a jar, and Executor will turn the jar into a Windows .exe file, indistinguishable from a native application. Simply double-clicking the .exe file will invoke the Java Runtime Environment and launch your application.
If your program is "publicly available non-commercial in nature" and has "a publicly available Web site that meets the basic quality standards", then you can try and get a free license of Excelsior. If its not then it's expensive, but still a viable option.
Program: https://www.excelsiorjet.com
As a side note: Here's a study of all existing Jar to EXE programs, which is a bit depressing - https://www.excelsior-usa.com/articles/java-to-exe.html
Despite this being against the general SO policy on these matters, this seems to be what the OP genuinely wants:
http://www.google.com/search?btnG=1&pws=0&q=java+executable+wrapper
If you'd like, you could also try creating the appropriate batch or script file containing the single line:
java -jar MyJar.jar
Or in many cases on windows just double clicking the executable jar.
I used Launch4J and it works flawlessy,
First, Go to your jdk and copy the bin and lib folder
Then create a folder for your app and make a folder called jre-(version),
Then paste these inside
Then open launch4j Put the exe file's path (Inside the app's folder)
Then go the jre option and inside bundled paths type jre-(version)
Then in minimun version type the version of the java you coded it in.
Then in the jre option put "Only use private jdk runtimes"
Then hit the gear icon. It will open a file chooser.
Choose your application's folder, done
Now open the exe file generated. It should work.
In case it does not, try the test run button (The green play one). If it says LinkageError in the console below, then in the jvm-options type --enable-preview. It should work.
I hope it helped.
For Windows, you can convert jar to exe using following ways:
Using Netbeans
https://erainnovator.com/convert-jar-to-exe-file/
Using Excelsior JET
https://youtu.be/iQSfUb8chjg
if you need to convert from .jar to .exe from java 14 you can used jpackage
jpackage is a command-line tool to create native installers and
packages for Java applications.
this article will help you