Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

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 javac 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:ProjectsJava you must compile it this way javac C:ProjectsJavaMain.java.

Then you can run your program this way too java C:ProjectsJavaMain

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...