ReventonMC ReventonMC - 2 months ago 17
Java Question

Javac classpath (.java file)

I want to compile a java file from the command line using this command:

javac -cp C:/Java myPgm.java
but it keeps saying that

javac: file not found: myPgm.java
Usage: javac <options> <source files>
use -help for a list of possible options


any help please? ;)enter image description here

Answer

run the following code in the terminal to compile the java source code

javac C:/Java/myPgm.java

then to execute the code

java theClassNameOfTheJavaFile