Quantcast

Jump to content


Photo

Java - Classpath problems.


  • Please log in to reply
3 replies to this topic

#1 Eeyore

Eeyore
  • <img src ='http://i34.tinypic.com/2mecsg1.jpg'>

  • 7908 posts


Users Awards

Posted 21 March 2011 - 06:18 AM

Sooo you guessed from the title I'm new to this, and I've basically spent four hours on and off trying to figure out what the flip I'm doing wrong via the internet/my book and as far as I can tell I have everything set up right...except I get errors so I clearly haven't.

My book is teaching me about packages, I've created a simple one with only two class files in it and their corresponding java files. The package is called org.cadenhead.ecommerce so the full thing for my directory is C:\java\org\cadenhead\ecommerce and I've got C:\java\ as my classpath. The class I'm trying to execute is called GiftShop and is located C:\J21Work\Giftshop.class. It's compiled fine, as have the other two classes in the package, but now it's throwing up that all too common 'Exception in thread "main" java.lang.NoClassDefFoundError' which I've read up to mean my classpath is set up wrong.

Any solutions I've found I either can't make sense of or aren't working. I've had to mess around with it all so much to try and get there because my laptop seems to need completely restarting every time to change the classpath for java to notice. I'm know it must be really simple to suss and I'm missing something so obvious but I've deleted and done it all from scratch so many times and tried so many different folder destinations for all this stuff which has finally got me this far....now I can't get the last bit to run.

I know I've only just come back and I'm already asking for help, buuuuut:
1. I'm pretty sure this is actually dead simple and I'm an idiot
2. In the past I have put hours of effort into this site... in stuff that has since been ditched so I have nothing to show for it...but yeah :p.
3. I'll love you <3.

Edit!! Never mind!! I did it all on my own! HAH. Take that Java!!

Anyway, I suppose now this topic needs a different subject matter. Erm....anyone learnt a new language lately? Any totally embarrassing and stupid mistakes you wanna share? :D

#2 Ladida

Ladida
  • Night Owl 🌛

  • 2152 posts


Users Awards

Posted 21 March 2011 - 08:51 AM

Oh my gosh I HATE classpaths with a vengeance!

#3 Eeyore

Eeyore
  • <img src ='http://i34.tinypic.com/2mecsg1.jpg'>

  • 7908 posts


Users Awards

Posted 21 March 2011 - 09:08 AM

Oh my gosh I HATE classpaths with a vengeance!


Haha tell me about it. I think I hate them more simply because I know full well the mistakes I'm making must be really obvious because I'm so new to it all! Turned out, after hours of rewriting everything, rearranging everything, endlessly restarting my computer, I missed a .; at the start of my classpath. What a fool I am!

#4 SpartanDuelr

SpartanDuelr
  • 16 posts

Posted 20 April 2011 - 09:41 PM

Sooo you guessed from the title I'm new to this, and I've basically spent four hours on and off trying to figure out what the flip I'm doing wrong via the internet/my book and as far as I can tell I have everything set up right...except I get errors so I clearly haven't.

My book is teaching me about packages, I've created a simple one with only two class files in it and their corresponding java files. The package is called org.cadenhead.ecommerce so the full thing for my directory is C:\java\org\cadenhead\ecommerce and I've got C:\java\ as my classpath. The class I'm trying to execute is called GiftShop and is located C:\J21Work\Giftshop.class. It's compiled fine, as have the other two classes in the package, but now it's throwing up that all too common 'Exception in thread "main" java.lang.NoClassDefFoundError' which I've read up to mean my classpath is set up wrong.

Any solutions I've found I either can't make sense of or aren't working. I've had to mess around with it all so much to try and get there because my laptop seems to need completely restarting every time to change the classpath for java to notice. I'm know it must be really simple to suss and I'm missing something so obvious but I've deleted and done it all from scratch so many times and tried so many different folder destinations for all this stuff which has finally got me this far....now I can't get the last bit to run.

I know I've only just come back and I'm already asking for help, buuuuut:
1. I'm pretty sure this is actually dead simple and I'm an idiot
2. In the past I have put hours of effort into this site... in stuff that has since been ditched so I have nothing to show for it...but yeah :p.
3. I'll love you <3.

Edit!! Never mind!! I did it all on my own! HAH. Take that Java!!

Anyway, I suppose now this topic needs a different subject matter. Erm....anyone learnt a new language lately? Any totally embarrassing and stupid mistakes you wanna share? :D

============================================================================================================================================

Well I couldn't say whats definitely wrong without the source code, but one reason for it not working that you didn't "IMPORT" your package into the class you are executing.

And don't worry in programming you always run into some road blocks and a lot of errors to troubleshoot.
For example, i was in a programming competition and my team was solving one of the problems. We did finish solving and coding the problem, but....... there was errors
my team tried to troubleshoot it for 45 min in a about 2-3 hour competition which took up a lot of time. And all it came down to was a Syntax error of a SINGLE BRACKET!!!!

if you still have problems try this link it looks like it has everything you might need
Java Using Packages


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users