Deploying a Java project to client on Linux system

2019-05-15 07:28发布

I'd developed a project using Java and now I've to deliver it to client who is using Linux. Can anybody tell me which executable file format will be delivered and how to make that?

5条回答
我命由我不由天
2楼-- · 2019-05-15 07:58

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

查看更多
Viruses.
3楼-- · 2019-05-15 08:10

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.

查看更多
4楼-- · 2019-05-15 08:15

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.

查看更多
\"骚年 ilove
5楼-- · 2019-05-15 08:19

A jar. If it is not executable, then a script (.sh) to launch the jar.

查看更多
相关推荐>>
6楼-- · 2019-05-15 08:22

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.

查看更多
登录 后发表回答