To java -jar or not to java -jar
I'm "going to get technical" on yous since I spent some time on this at work trying to figure out what the f-ing hell I was doing wrong, and to remind myself in case I ever needed to work this out in the future.You CAN jar up a bunch of classes, specifying your main class to execute, and the classpath with which to execute it with by calling:
java -jar
BUT, you must.. and I cannot stress that enough, specify which class is your Main-Class in the jar's manifest.mf file (who would've thunk...):
Main-Class: com.package.my.main.class
AND, you must.. and I again cannot stress this enough, specify the classpath for your class. Easy you say? Yep it is, if you remember to use RELATIVE PATHS for any jars you need. Yes you read it right, relative, not absolute, only relative... separating them with spaces, not semi colons or colons, spaces.
Class-Path: ../../some-silly-jar.jar ../some-other-silly-jar.jar
And you can use ant to jar up your files and specify those attributes for you too. No examples for this one though, (I'm at home now, not at work ;)
1 Comments:
You write very well.
Post a Comment
<< Home