Reputation: 11
I've implemented "Java Compile" and "Compile and Run" (the second as Java Compile and Run) as described in this answer: Java compile and run using notepad++ and nppexec.
Note: I'm using 1.8.0_20 rather than 1.7.0 as described in the answer.
However, when I try to run HelloWorld (as found here: http://docs.oracle.com/javase/8/javafx/get-started-tutorial/hello_world.htm) to test the compiler, I get the following response, including a "Could not find or load main class" error:
NPP_EXEC: "Java Compile and Run"
CD: C:\Users\Bova\Documents
Current directory: C:\Users\Bova\Documents
"C:\Program Files (x86)\Java\jdk1.8.0_20\bin\java" -classpath "C:\Users\Bova\Documents" "HelloWorld"
Process started >>>
Error: Could not find or load main class HelloWorld
<<< Process finished. (Exit code 1)
================ READY ================
What do I need to change to avoid this error?
Upvotes: 0
Views: 4795
Reputation: 83
I had this problem in Notepad++ too. What I did to fix it was I went to the Plugins menu, clicked on NppExec, and selected Follow $(CURRENT_DIRECTORY)
. After that I can run programs just fine.
Upvotes: 1
Reputation: 33116
The very first line of HelloWorld.java
reads:
package helloworld;
Java packages are mapped to directories on the filesystem, so the interpreter expects to find HelloWorld.class
inside a helloworld
directory. Move the .class
file to a helloworld
subdir and run it as:
> java helloworld.HelloWorld
from the parent directory (i.e. the directory which contains helloworld/
).
Upvotes: 0