Hy guys! Today i am going to show you how to run java from Command Prompt. You are going to learn to setup the environment variables to run java using Command Prompt. So, here we go:
To run java you must install JDK. If you dont have it download it from :
Setting Environment Variables:
- Right Click Computer
- Click Advanced System Settings under properties
- Click New under Environment Variables
- Set ”path” as Variable name
- For Variable value you need to go to the folder where you installed JDK
- Inside JDK installation directory open subdirectory bin
- Right Click any file inside that directory Under properties
- Copy the address of the file that address is Actually the Variable value of variable path press “ok”
Open Command Prompt and type javac alot of crap will show up. This is the indication that you’re ready to go!
In Command Prompt change your current directory to the directory in which u saved the file which u want to run
type java FileName.java is the command to execute the java code FileName is the name of .class file.