MAC OSX
I have the java source file A.java in "$HOME/Documents/personal_documents/java".
class A
{
public static void main(String args[])
{
}
}
Executed following commands:-
- cd $HOME/Documents/personal_documents/java
- javac A.java ('Got successfully executed')
- java A ('Threw the error': Error: Could not find or load main class A , Caused by: java.lang.ClassNotFoundException: A)
Troubleshooting I did on my part:-
/usr/libexec/java_home
/Users/rishabshinghal/Library/Java/JavaVirtualMachines/openjdk-14.0.1/Contents/Home
Tried setting JAVA_HOME, PATH env variables explicitly.
export PATH=$PATH:$HOME/Library/Java/JavaVirtualMachines/openjdk-14.0.1/Contents/Home/bin
export JAVA_HOME=$(/usr/libexec/java_home)
Tried executing javac, java using absolute paths
$HOME/Library/Java/JavaVirtualMachines/openjdk-14.0.1/Contents/Home/bin/javac A.java
$HOME/Library/Java/JavaVirtualMachines/openjdk-14.0.1/Contents/Home/bin/java A
Also tried setting classpath explicitly even though I am in the same directory as class file.
javac A.java
java -cp . A
Please help me in this. I spent lot of time in troubleshooting this but didn't get any breakthrough.