IzPack, can it output a single executable jar? - java

I found some great tutorials for IzPack and it works great at installing my program into a folder. Is it possible to have the contents of those folder wrapped into an executable jar using IzPack? My goal would be to have that executable jar call my python script which launches the application. Let me know what I can do, thanks.

I don't think so. Not because IzPak did not have the capability to do that (it obviously creates the installer's jar), but because it was not designed to do so, AFAIK.
If you want to pack various jars in a single jar file, then you should attack this problem in the build phase of your project. If you use Netbeans, then this link will be useful:
http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/
About executing the python script... are you using Jython? If not, take into account it is quite difficult to distribute a python program, many apps written in python distribute the interpreter and its required dll's with them.

Related

Eclipse jar to an exe?

I've searched far and wide, I can create my JAR using eclipse but when I run it, it doesn't run half of the program because it didnt import the API's, because the API's don't exist in the JAR.
I made a simple pac-man game (still learning java :O)
I compiled it into an executable JAR so I could use a program called 4J to turn it into an exe!
However, the JAR doesn't even run the game :/
Don't know what sources you need, so just ask.
Sorry I'm a newb D:
You can supply third-party API within your jar file. This is so called fat jar approach (all classes will be put into one jar according to names of the packages). So you will deal with one jar file (then convert it to exe, or add shell scripts for specific operating systems which will just run java -jar game.jar - too many options).
As for Eclipse search for specific plugins. Or, as mentioned above, use Maven or tool that will give you a portable installer. It's completely up to you.

run java console program in unix

I have some code in Java using Eclipse and I would like to deploy it to unix envirnment. The program is simple console program that just takes some arguments at the run time, read a file and print out some results.
My question that what is best approach to deploy and run it in unix envirnment. I was just thinking to copy all the classes file to the unix envirnment and create a batch file to run the main class file. Does this sound okay? Or, should I create a runnable jar file?
Also, where should i put the jar files that the prgram is referencing (in classpath)?
Thanks
I think an executable jar file will solve your purpose here.
You should be able to execute it as
java -jar <jarfilename> <arguement1> <arguement2> .... <arguementN>
You can execute the jar file from the current directory itself, just make sure your jar file has executable permissions.
chmod +x <jarfilename>
ls -la
Designing for easy deployment is important in my opinion.
In our case, there are some components:
store project in the source code management system (git). we break down source code as
the developing source code to dev branch
the stable source code to release branch
use build tool, such as ant or maven, and provide a deploy script in the project. (we will talk deploy script in 3.).
provide deploy script to:
fetch the latest stable source code in the build server
build to executable files in the build server (whatever you do)
send the package to the target server
launcher (close the old app and run the new app) in the target server (via remote ssh command)
Currently, you think how to package the java, but it is a simple thing just about building and runing. When you talk about deployment, make it as easy as possible. Each time we deploy just to invoke the release script.
PS. I don't like the executable jar. Using un-packaging jars and compiled class can be sending by rsync very efficiently.
It sounds Ok and will work for you. Just one fix: you are going to write shell script for unix, not batch file.
But you can do better. Typically java classes are packaged into jar file. Jar file is just a zip file with optional META-INF, directory, MANIFEST.MF and other stuff. So it is better to package your application into jar and then run it as: java -cp yourjar.jar YourMainClass.
To create jar file you can use any tool that can create zip or utility jar that is a part of your JDK. You can also create automatic build using ant, maven, gradle, bildr etc that will help you to package your application.
I would do the following:
create a dedicated directory for this program. Copy the dependent .jar files to that directory
write a (short) script that sets the classpath to point to these jars and then executes the main class
Given the above, it's largely a matter of style as to whether you create a runnable .jar or not. It'll be hidden from the user.
I'm suggesting a script because:
you can set regularly used JVM parameters easily (memory options etc.)
it's a pain (and hardly intuitive) to type java -jar {pathtojar} etc.
By copying the jars to a dedicated directory, you can then use different versions of jars for different scripts (e.g. you may have 2 programs that use two different versions of commons-lang)
You should also (probably) use this script to explicitly determine which version of Java you use to run the program with. As you install/upgrade you don't want to break your programs and the scripts can be configured to explicitly tie down this info.
I find this quickest of all:
First, create a jar, copy to unix server and change file permission just as dopplesoldner mentioned below.
You can put your library classes and or jar dependencies in a lib folder
Then execute the jar
java -Djava.ext.dirs=lib/ -classpath yourJar.jar com.yourPackage.yourClass
yourClass will be the class having main(String args[]) method you wanted to execute.

Have a Java application (JAR) that needs to be executable. (Built In Eclipse)

I have this little application (JAR) built in Java on Eclipse and it needs to be compiled into an executable file that people can just double-click and it runs. Ideally this would an exe filetype. I'm not so versed with java and what the needs are but I'm hoping it can be compiled to run one computers that maybe don't have java installed.
Is there any advice or direction you can point me to so I can figure this out?
Many thanks.
Ideally this would an exe filetype.
No, ideally this would be a Jar file. Just leave it be a jar file. It will work fine if you set up your platform to respond to double clicks correctly. And yes the computer will need to have Java installed -- that's not an onerous requirement.
Try this application : exe4j : http://www.ej-technologies.com/products/exe4j/overview.html
It runs on various platforms to made EXE files :))
You won't be able to make it run on PCs without Java installed.
There are plenty of guides on how to make an executable jar to run on computers with Java installed: take your pick: java executable jar creation, Make JAR as a standalone executable and so on...
You can try http://www.excelsior-usa.com/jet.html. It is free for non-commercial use.

Best option for packaging a Java CLI app for OS/X and Unix?

What's the best option for packaging and distributing a command line application written in Java, targetting OS/X and Unix?
The executable jar option seems fairly robust, and my distribution doesn't need to be super fancy, so right now I'm just thinking of plonking a bash script next to that with the relevant java invocation and being done with it.
I'm wondering if there's something similar to python's bdist package that would let me easily make nice installers for both target platforms. Or if there's some more obvious way that I'm missing where I can turn the entire distribution in to a executable file that wraps the jar in some way.
Since you are providing a CLI application it may be easiest to just provide the script you already mentioned. I usually try to keep it self-contained, e. g. not referencing external paths / using only relative paths etc. And maybe a readme.txt file.
If you would like to provide a full-blown installer, you might want to take a look at IzPack, a tool for generating installers for Java deliverables. It also allows the wizard to run in console mode, if you do not have a graphical environment available for installation (see the "Features" page in the link above).

packaging java application

I have a java application from which I build a jar that relies on many third party jars, what's the best/common way of packaging this application for end user distribution?
The best way is to use a build tool like Maven2 or something similar, and use that to manage your dependencies and build a all-in-one package.
Otherwise, you'd mostly be stuck with messing with manifest files. Although, IDEs like Eclipse or NetBeans may help you a bit with that.
The way packaging is done. There are two ways
wrap as executable: This is common, if you know the supportable platform and wrap the Jar in executable. And distribute it. Something like this http://launch4j.sourceforge.net/ (I have not used this, but there are similar wrapper available)
Bundle all Jar and provide script: You can use Maven's Assembly plug-in to bundle everything in one Jar. With this done, you can distribute with a bat file and a .sh file for Windows and Linux based systems respectively. If you see Glassfish is distributed in similar manner. These scripts has executable command and, often take parameters for different behaviors.
You can also use Fat Jar Eclipse Plug-In
OR
Packaging and Deploying Desktop Java Applications in NetBeans

Categories