简体   繁体   中英

run the jar file created from windows in linux as executable

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM