Hydrox Hydrox - 2 years ago 113
Java Question

How to compile a java project with a terminal/cmd

I got tired of using Eclipse because it was too "plain" and "old style". So I moved on to a program called Sublime Text 3 and I used a package named "material theme" which made the program look flat and all nice and stuff.

But I wanted to code Java in that but I don't know how to compile stuff without using an IDE and it was not easy to find out but I found out that you could do it through the terminal/cmd of your operating system.

But what I don't understand is how I could actually use the

command which means Java Compile and I searched and I didn't find out because I couldn't understand anything that was posted on either YouTube or Stack Overflow because I'm new to this whole terminal/cmd Java Compiling thing.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download