It is common approach to provide os specific scripts(bat/sh files) to launch java application.
There any many products which help you to create native launchers for java application. These products
JLibs comes with JLaunch scripts which help java developers to overcome these problems.
you will find two script files:
these script files take a conf file as argument. This conf file contains all the information like classpath, system properties etc.
to launch your java app on windows:
to launch the same app on nix:
the working directory of java process launched will the directory in which conf file is present.
any additional arguments after conf file are passed as main class arguments
path/to/jlauncher.sh path/to/myapp.conf arg1 arg2 arg3
let us see a sample conf file:
<java.classpath> engine.jar ui.jar jdom.jar <java.endorsed.dirs> lib/endorsed <java.ext.dirs> lib/ext <java.library.path> lib <java.system.props> # use mx4j mbean server javax.management.builder.initial=mx4j.server.MX4JMBeanServerBuilder # logging properties java.util.logging=mylog.properties <java.bootclasspath.prepend> #lib/mxj4.jar <jvm.args> -showversion com.foo.MyApplication -open some/file
The conf file is composed of following sections:
<java.classpath> <java.endorsed.dirs> <java.ext.dirs> <java.library.path> <java.system.props> <java.bootclasspath> <java.bootclasspath.prepend> <java.bootclasspath.append> <jvm.args>
Rather than asking end user to type "jlaunch.sh myapp.conf" to launch your java app, you can create simple wrappers as explained below:
Your comments are appreciated;