开发者

How to launch java application without having to specify classpath?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜