Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another Error this time while trying to run "cannot find class"?

 
Ryan McKay
Greenhorn
Posts: 8
Android Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone again. Thank you so much for all the help you've been to me thus far. I'm working on my third program from the book Head First Java, it compiles ok, but when I try to run it I get this error.


Here is the code in my java file.

Can anyone help point out my failings? I've tried to figure it out on my own, but I'm just stuck. Again. lol thanks for the help in advance!
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a reason your class isn't declared public?
 
Ryan McKay
Greenhorn
Posts: 8
Android Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not really, just how the book had it. I did try it with public class Shuffle1 { as well but it had the same error.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code runs fine when I compile it. Is this all the code in the file? That is, do you have a package statement at the top of the file?
 
Ryan McKay
Greenhorn
Posts: 8
Android Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no that's everything I have, no package statement. Out of curiosity, what is a package statement? Sorry for the noob questions.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the current directory is not in the classpath. Try "java -cp . Shuffle1" instead.
 
Death Arte
Greenhorn
Posts: 21
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Ryan McKay

Just follow Sir Christophe said..

Here's my command line code which is same as Sir Christophe Verré code.

java -classpath . Shuffle1


Have a nice day Sir!
 
Ryan McKay
Greenhorn
Posts: 8
Android Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah then wait, this must be because I added the classpath and path to my environment variables? Didn't know that would cause these kinds of problems.


Trying it now.

Thanks! That did it! One more thing to remember. lol.
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan McKay wrote:...what is a package statement?

Packaging is a way to separate your code in terms of their functionality. They act as kind of a namespace for your code. It make the code easier to manage and reuse. And it avoids the conflicts which otherwise may occur if you have same function in two different classes with same (or default) package.
I added the classpath...

Don't set the classpath.
 
Ryan McKay
Greenhorn
Posts: 8
Android Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:
I added the classpath...

Don't set the classpath.


So just the path? or should I do neither and just write the path out all the time?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The PATH is used to find java/javac so you should leave it instead of having to always type the full path.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic