How to compile a java project with a terminal/cmd

You’re almost there buddy!

Just be sure you have the Java Development Kit (JDK) installed in your system. The JDK provides you the command javac -which you need to compile your .java program files.

The javac command is not that friendly as you think it is. You have to let it know where to find the java file you want to compile.

For example you saved Main.java inside C:\Projects\Java you must compile it this way javac C:\Projects\Java\Main.java.

Then you can run your program this way too java C:\Projects\Java\Main

As mentioned here… You can find a more detailed explanation to the official tutorial.

Leave a Comment