Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

java - Creating standalone Mac App from JAR file

I'm new to java but have built an application in eclipse which functions as intended. The end goal is to create a standalone .app with an icon for a user to click to run the application.

I've exported the project and created a standalone .jar file which when I double click, does not open. I get the error "The Java JAR file "File Name.jar" could not be launched. Check the Console for possible error messages." And when I look in the console, I don't see any error messages.

When I try to open my jar file in terminal with "java filename.jar", I get the error: "Error: could not find or load main class". However, when I launch the jar file in terminal, with "java -jar filename.jar" it opens fine.

I've packaged up the app using JarBundler, however the final .app file does not work either.

I don't know what to troubleshoot in order to get the .app file to open. Do I need my standalone executable jar to be able open without calling "java -jar", or is that unrelated? Why would my java file open with that but not without? Any guidance would be greatly appreciated.

question from:https://stackoverflow.com/questions/65864786/creating-standalone-mac-app-from-jar-file

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

1 Reply

0 votes
by (71.8m points)

You can use jpackage to create installable packages for Linux, Windows, and macOS. It's part of the JDK, so no need for extra tools.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...