Deploying a Java project on Linux system

大憨熊 提交于 2019-12-22 06:39:11

问题


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?


回答1:


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




回答2:


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.




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/7794493/deploying-a-java-project-on-linux-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!