This question has been asked before but I still cannot figure whats wrong for some reason.
I got a class named NewClass in package syntaxtest in file src. From src path I type :
javac src/syntaxtest/NewClass.java
and the class is compiled and I can see NewClass.class in syntaxtest folder. Now from that same path or even the same folder with NewClass.class, I can’t figure out how to run the class from terminal. I have made many different attempts but ether I get
ClassDefNotFound or ClassDefNotFound (wrong name : syntaxtest/NewClass)
Try “
java -cp src syntaxtest.NewClass“.That is, if you have a folder “src” which contains the subfolder (package) “syntaxtest” and the class “NewClass” is in “package syntaxtest”, then the above command will work.