How to run Java program by using CMD in Windows 10

For running a Java program first, you have to install a Java on your system.

copy the java folder to drive C, then run the Jcreator software LE version setup ( I used jcrea500_setup.exe)

JCreator is backwards-compatible with all previous version of the JDKs published by Sun Microsystems. The following releases have been tested.

JDK 1.6.0
JDK 1.5.0
JDK 1.4.2  -preferred version
JDK 1.2.2
JDK 1.0.2

on CMD : CD java then set the path of the JDK which is on the bin folder. Make sure to change the directory first to c:\java\bin> 

path

 

to check if it is already set, the version of Java will be displayed on the screen.

version

 

to run my first Java program, I used Notepad++ as my text editor

Save it in the bin folder ,the filename should be the same with the class name and with a java extension.

Exer1Java

To compile: on CMD write javac which is a Java compiler, it compiles the Java program and converts our Java code into Java bytecode.

compile

*on CMD just press the TAB to show up the saved file. If multiple files just keep pressing the TAB button to alter the files.

If no errors on compilation the program is saved to .class filename.  By typing Dir *.class the program should be on the list.

syntaxC:\java\bin>Dir *.class

class

Now, we can run the program to show the output by typing java_filename(no extension needed).

output

 

 

Leave a comment