简体   繁体   中英

How to run a Java program (distributed as a Windows exe) under Linux?

I have a very simple JAVA app that is distributed as a single Windows executable file and I would like to run it on a Linux computer. I could extract the content of the exe file with 7-zip, but I don't know what to do next.

There are multiple levels of subfolders with .class files and image files for the software's user interface (no source files).

The root folder doesn't contain any class files, but it contains many subfolders, including a META-INF subfolder. This META-INF folder contains one MANIFEST.MF file, in which there is a line like this: Main-Class: subfolder1.subfolder2.Software

How can I make it run? Is there a way to run it on a Linux computer's JVM?

I extracted the content of the Windows executable file with 7-ZIP, created a JAR file and executed it with these commands:

cd MyAppName
jar cfm MyAppName.jar .\META-INF\MANIFEST.MF .
java -jar MyAppName.jar

You likely cannot do what you are looking to do using the .exe as that is a program that was compiled specifically for Windows. To get it to run on Linux, you would either have to recompile it to a runnable file on Linux, or make it a jar file.

Making it a .jar file would allow it to run on any machine that has a Java Virtual Machine installed on it and would allow your program to be platform independent.

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