• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Greenhorn
Posts: 8
Android Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 27454
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe the current directory is not in the classpath. Try "java -cp . Shuffle1" instead.
 
Greenhorn
Posts: 21
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Always look on the bright side of life. At least this ad is really tiny:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic