开发者

How to launch java application without having to specify classpath?

开发者 https://www.devze.com 2023-04-02 11:10 出处:网络
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 l

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

0

精彩评论

暂无评论...
验证码 换一张
取 消