I'm trying to run .class file from command line. It works when I manually move to the directory it's stored in, but when I try something like this:
java C:\Peter\Michael\Lazarus\Main
it says it can't find the main class. Is there any solution to this other than making a .jar file (I know that .jar is the best solution, but at this moment isn't the one I'm looking for)?
解决方案
The Java application launcher (a.k.a java.exe or simply java) expects a class name as its argument, so you can't pass it a file name (especially not one that includes a directory.
You can tell it where to look for that class by using the -classpath option (or its short form -cp) however:
java -classpath C:\Peter\Michael\Lazarus\ Main