I have a simple program that works fine in a previous environment. I've moved it to a new one with the same OS and Java versions, but have encountered a problem executing the class files.
Never have I had a problem running a java class in the same directory but when I try java Class
I get the error could not find or load main class
.
I've already looked over all the suggestions, one of the most popular being to add the classpath and run it as java -cp . Class
. However this has never been necessary in all the environments I've worked in, including the previous one which was identical to this. Why would this happen and how can I fix it?
Note: In case you wonder, java -cp . Class
works for a small test program with no dependencies, but results in a JNI error which has no clear resolution, related to a jar file that is both on the bashrc classpath and the current directory (when specifying -cp .
). Regardless, I just want to execute classes like normal.
UPDATE
I'm certain this is an environment issue, but here is the code. I am calling it as java Test
, NOT java test
or java Test.class
.
class Test {
public static void main(String[] args) {
System.out.println("Test complete!");
}
}
CLASSPATH
environment variable set?