Question

I have created a java application and packed it into a jar file on a Windows platform. Now I wants to deploy that jar file on Debian Linux.

  1. Will the same jar file work for Debian Linux?

  2. Is the command, used in windows for executing a jar file from the command prompt, same for Debain Linux?

i.e.

java -jvm "MyJar.jar"

Will the above command work for Debian Linux?

Was it helpful?

Solution

Yes.

Jar files are portable across platforms, and the syntax of the jar command is the same on both Linux and Windows.


EDIT: You should use the latest version of Sun Java unless there is a very good reason not to. Installation instructions: http://wiki.debian.org/Java/Sun

OTHER TIPS

Generally, it should. However this depends on a few conditions:

  • If you use native code (JNI) you must make sure that the native library is available for the target platform
  • You must make sure you have no paths hardcoded which are Windows specific (in fact you should even watch out for special characters like the Path seperator : vs. ;)
  • You cannot use Runtime specific code

1. Will the same jar file work for Debian Linux?

Yes. Hence the nature of Java (portable code)

2. Is the command, used in windows for executing a jar file from the command prompt, same for Debain Linux?

java -jar "MyJar.jar"

yes, the main idea of java is that it (should) run on different operating systems, as long as a java runtime is installed.

though i have never heard of the -jvm flag.

if you want to start a jar file you should use the -jar flag.

java -jar "MyJar.jar"

you can also read up on the Write once run anywhere principle.

I do my development on a mac but run in linux and windows environments without any problem. Key is not to use JNI, As everyone else have mentioned I would use java -jar "MyJar.jar"

Almost. Use:

java -jar "MyJar.jar"

And of course you shouldn't have used anything such JNI or runtime stuff

Yes, although you might want to do, in Linux:

java -jar YourJar.jar

Instead of:

java -jvm YourJar.jar
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top