4

Hi I have developed a swing application using javafx on Windows operating system . It's working fine on Windows. But when I run the jar on Linux it's defaulting to opening in the archive manager, it's not working as an executable.

I have checked the properties of the jar file, it's an executable already.

Do I have to recompile the source file in a Linux environment to run this jar file on Linux or will the jar file work on Linux also?

Kitalda
  • 351
  • 2
  • 18
adesh singh
  • 1,727
  • 9
  • 38
  • 70
  • Please read the link [Executing a jar file in linux][1] [1]: http://stackoverflow.com/questions/6724953/executing-a-jar-file-in-linux – rudrasiva86 Jan 28 '13 at 09:02

2 Answers2

8

If you've not used an operating system dependent commands like running a windows command from java (which will not run in linux for sure) or using a windows specific module, your java will run in all other operating systems. This is one of the most significant features of java which is cross-platform and you can run your code in different operating systems which has that operating system specific java runtime environment installed.

So in all operating systems, just you have to run

java -jar yourjarfile.jar
Vahid Farahmand
  • 2,528
  • 2
  • 14
  • 20
0

executable jar has to be executable across the operating systems.

However, you need to check the permission of the .jar file . especially when executing in linux like environment.

chmod +x /path/to/your/java.jar

use chmod command in linux / modify your buil.xml using Ant chmod

TheWhiteRabbit
  • 15,480
  • 4
  • 33
  • 57