Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

java - How do I run a JAR file in Ubuntu that was compiled on windows?

I compiled the Java project on Windows with java 1.8, it worked fine on my windows machine, then in my Ubuntu I set it up with Java 1.8 too, now Ubuntu says can’t find Main class, I researched the problem, didn’t help, I suspect it has something to do with the folder path, but i copied the entire project folder compiled by net-beans to my Ubuntu. my manifest file contents :

Manifest-Version: 1.0

X-COMMENT: Main-Class will be added automatically by build

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your manifest file doesn't list the main class as well as the class path dependencies. So that means when you run the jar, you have to run by providing the class path as well as the main program to run.

For e.g.

java -cp /path/to/my/jar/dependencies -jar file.jar com.package.of.my.main.class.MyMainClass "any arguments if any"

Or have your manifest file provide both the class path and the main class and just run

java -jar file.jar


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...