[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: Help with jar export and external library

Paul Rubin wrote:
Eric Rizzo wrote:
Paul Rubin wrote:

I don't suppose anybody has found a better way to get around Java ignoring -cp when running a jar?

I was not aware of that side-effect of using java "-jar" but in any case you don't have to resort to deploying an exploded JAR (.class files). You can still ship a JAR and a batch file, just instead of using "java -jar ..." you include your JAR on the -cp arg to java.exe or javaw.exe. The -jar shorthand is just a convenience method, you can ignore it when it doesn't meet your needs.

Simple, elegant, works like a charm. Thanks! My app doesn't require much in the way of launching (I wrote a one-line batch file to launch it). I had just assumed (incorrectly) that if you launched a class rather than a jar, the class containing the main method had to reside in the file system (rather than in an archive). Wouldn't have thought to try this without the tip.

Heh - this is what you might call a "generation gap" in the Java world. Until Java 1.4 (or was it 1.3? I can't remember) there was no -jar option to java.exe. And any programmer who began before sophisticated tools like Eclipse and Ant was forced to know all the details of launching a Java program.


Anyway, I'm glad you got where you needed to go, and I'd recommend you follow up and learn everything about launching the JVM - there's lots in there that IDEs hide from you and you may want/need to be aware of at some point in the future.

Eric