• Post Reply Bookmark Topic Watch Topic
  • New Topic

Executable jar problem  RSS feed

 
Michael MacEachran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not done this in years so maybe I am missing something simple but.....

I have some classes that generate reports. I want to schedule these reports to run in the morning. I go and use Quartz scheduler. I run in Eclipse, everything is fine.

I of course do not want to keep an instance of Eclipse up on the production server just to run reports!

I jar everything up (Using ant if that matters, but the same jar file works on production) I explore the jar, and ant put the correct MANIFEST file in there. the main class is com.x.reports.ReportScheduler

I run this:

java -jar reports.jar

I get the NoClassDefFound error for the quartz jar file.

so I do this:

java -classpath C:\AntStage\lib\quartz-1.7.3.jar -jar reports.jar

Still NoClassDefFound !!!

I test to see if the .class files are messed up and run this:

java -classpath C:\AntStage\bin;C:\AntStage\lib\quartz-1.7.3.jar com.x.reports.ReportScheduler

Works fine!!!

Is there something about jaring everything up that messes with the -classpath?
because the .jar is just the /bin directory jared up, so I don't see what the difference is.


 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ALL classes (whether loose class files or jar files) must be in the classpath. It sounds as if the loose class files are in C:\AntStage\bin/com/x/reports/..., in which case the "-classpath C:\AntStage\lib\quartz-1.7.3.jar" would have prevented the JVM from finding them.

You might consider writing a small batch file that sets the classpath and starts the program; that way you have something double-clickable.

Or look into the details of the manifest file that's in the jar file - it has options for setting the classpath; that would still give you something double-clickable.
 
Michael MacEachran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I go ahead and try adding the classpath to the MANIFEST like this:
<attribute name="Class-Path" value="C:/AntStage/lib/quartz-1.7.3.jar"/>

and now it cant find the main-class !!! I tried adding "." to the classpath like this:
<attribute name="Class-Path" value=".;C:/AntStage/lib/quartz-1.7.3.jar"/>

But then it could not find the quartz classes!

it's like it will only take one classpath.

for now, This is working:

java -classpath C:\AntStage\lib\MyReports.jar;C:\AntStage\lib\quartz-1.7.3.jar;C:\AntStage\lib\commons-logging-1.1.jar com.x.scheduler.ReportScheduler

but that seems to defeat the point of an executable jar....
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A manifest is not an XML file: http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html
 
Michael MacEachran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I was not clear... That was the line that I added in my ant build.xml to make the jar...
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us the contents of the generated manifest file.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!