• Post Reply Bookmark Topic Watch Topic
  • New Topic

jars and classpaths  RSS feed

 
Zachary Anderson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello JavaRanch, [Sorry, I know I've posted three questions and haven't been able to answer anyone else's questions... maybe when I learn more...]
. I've looked through the past eight pages so I don't think it's been asked recently, and it looks to be simple so I think this would be the right place for the question.
. I've created a jar DMS-DNMS.jar on my computer (using JBuilder), and gotten it to successfully run on another set of computers. Unfortunately, it doesn't look like it wants to run on this one. (and I'd want an executable jar rather than asking the users to java -cp .etc DMS... because the end users aren't programmers in the least) My best guess is that there's something screwy about the classpath. The user Desktops are on the F: drive, and jdk installed itself on the C: drive, but even when I copied the jar and pasted it into AppServer/jdk/bin, it didn't work. Either way when I double-click on the jar (and I had to do it lots of times to be able to finally read it) a Command window very briefly flashes "Exception in thread "main" java.lang.NoClassDefFoundError C:\Sun\AppServer\jdk\bin\DMS-DNMS/jar or D:\Documents and Settings\lab\Desktop\DMS-DNMS/jar"
. So... I think this is a classpath problem, but I'm not sure what to set it to. How do I check what the current classpath is, what does it want to be, and how do I make sure I'm not erasing a classpath that other programs need to function?
Thanks much,
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

First, don't worry. There is no ratio limit to the numbers of questions/answers you need to post here. Keep asking questions since that is the purpose of this ranch
And if you know some answers then by all means help the people if you can.

Also you can use the search button above to search through the questions instead of looking at the last 8 pages.

Now to your question: Like you guessed the problem is that java can't find your class file. Luckily, for executable jars like you have there is an easy solution called the Manifest file.
Basically it is a file you need to include in the jar to make it run and in it you specify the class that has the main function in it.
For examples and solutions look at this url:
Click here

Hope you will get it working,

Roy.
 
Zachary Anderson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hm. I was hoping that when JBuilder jarred something, it took care of the appropriate steps. Well, when I look at it with Windows' compressed folder utility, it shows the following folders structure:
com: Subset of mysql stuff
d20: Another program I was working on at the same time, not sure how it ended up in the same jar. It had a main, which I thought might be disrupting stuff, but it didn't work even after I removed this folder and tried to run it.
javax: For comm drivers.
META-INF: contains MANIFEST.MF, a file that has just
Manifest-Version: 1.0
Main-Class: mypackage.y

org: Another mysql package.
and mypackage: All the parts of my program, which does in fact have a main in the y class.

. After a bit of consideration, decided to try rerunning the jar. It works on all the computers I've tried so far, including the one I'm on right now... just not the new one. Not entirely scientific method, but I think it's fairly safe to say it's specific to that computer. So what should I look for?
(note to self and anyone who happens to be listening in... should have a step-by-step troubleshooter somewhere online, where you type in the error message, it asks you a series of questions... sort of like the Windows "print manager" thing (Try spinning three times widdershins. Did that work? Y/N) and then gives an analysis and prescriptions, and a forum-like thing if you go through all the prescriptions and still have a problem)
 
Zachary Anderson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There we go...
. Added instructions for Jar files to Windows Explorer. Runs fine on Cimarron now.
. (only oddity is a command window popping up on Cimarron, and it doesn't on Alpha or Beta; makes for the better error-checking, but it confuses users to go from one to the other)
. Generally happy with its behavior, though. :roll:

Computers are fun!!!11!1eleven!1!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!