-1

I've looked up why and I saw that the problem is either with not specifying the package or with the classpath. I don't use any packages so it must be with the classpath and I read some java documentation on it and I thought I figured out where to set it but it still doesn't work. I did

set classpath = C:\Program Files\Java\jdk1.8.0_60\lib\*;C:\Program Files\Java\jdk1.8.0_60\bin\*; 

but that didn't work, so I guess I have no clue what to set the classpath to. Am I just setting it to the wrong folder or is there a more significant problem?

a)

public class Hello_World{
    public static void main(String[] args){
        System.out.println("Hello World");

    }

}

b) I already ran javac Hello_world.java and got a class file and now I'm running java hello_world

c) the error message "Error: could not find or load main class Hello_World"

H. Guy
  • 25
  • 6
  • You probably want to include the current directory `.` in the classpath, unless your class file is in the JDK `lib` or `bin` directory. – Kayaman Sep 11 '15 at 13:16
  • Please show us a) your code; b) how you're trying to run it; c) the error message. Currently we don't have enough information to help you - we know you're doing *something* wrong, but we don't know what... – Jon Skeet Sep 11 '15 at 13:20
  • I included said edits into the question – H. Guy Sep 11 '15 at 13:26

1 Answers1

1

As suggested you shouldn't need to worry about adding lib and bin if Java is in your path. If your class is in the same directory as you are running java from, and no package as you say, then you should be able to do:

$ java Hello_World

or add current directory to classpath:

$ java -cp . Hello_World
jacks
  • 4,614
  • 24
  • 34