I'm new to java and I'm experimenting with hello world app. I've exported the app from Eclipse into a jar, i DID specify t开发者_运维知识库he launch configuration, and when I ran it from command line, I retrieved
Error: Could not find or load main class
That can be fixed by specifying class path like this:
java -cp .:myjar.jar MyMainClass
However, this is really inconvenient. Is there any way, preferably through eclipse, to specify MyMainClass as a metadata inside the jar file so I don't have to write it down every time I launch the app?
yes, you can by writing a manifest file, and then running java -jar Yourjarfile.jar
精彩评论