C
C
Core Java
Search…
3) Java setup
Java Set Up
For Executing Java program, you need to
    Download and Install JDK (from www.oracle.com)
    Set path of the Jdk/bin Directory
    Create the java program
    Compile and run the Java program
Path Variable
Path variable is set for providing path for all java tools like java, javac, javap, javah, jar, applet viewer which are used in java programming. These all tools are available in bin folders so we set path up to bin folders.
Classpath Variable
Classpath variable is set for providing path for predefined java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib folder.
JDK Folder Hierarchy
C:\Program Files\Java\jdk1.8.0_102\bin
This folder contains tools like java, javac, javap, javah, jar, appletviewer etc.
C:\Program Files\Java\jre1.8.0_102\lib
This folder contains rt.jar which contains all the predefined Java classes
Why set path?
To execute java console based programs in windows environment we have to use java and javac commands. Since, java and javac commands are unknown for windows till we do not specify explicitly where those executable resides.
The following programming error is general for all java programmers when they compile any java program without set up the path.
'javac' is not recognized as an internal or external command, operable program or batch file.
When you get this type of error, then your operating system cannot find the java compiler (javac). To solve this error, you need to set the PATH variable.
Javac is a tool which is available in bin folder so you must set the PATH upto bin folder. In a bin folder all tools are available like javap, javah, jar, javac, java, appletviewer etc. These all tools are used for different-different purpose.
How to set the path and classpath
Go to My Computer icon and right click ->click on properties option-> click on advance System setting -> Click on Environment Variables -> Select on path which is under second box (System variable Section). -> Click on edit -> Do not delete anything on variable value, just put a semicolon at the end and paste the bin path (C:\Program Files\Java\jdk1.8.0_102\bin)
Again put one more semicolon at the end and paste the lib path.
(C:\ProgramFiles\Java\jre1.8.0_102\lib)
You are done with path setting.
Restart your system
How to check whether java is installed on your computer?
Ans-Open command prompt->type ->java –version press Enter
If java is correctly installed then you will get something like this
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
Everything is done. It’s time to write program.
Last modified 2yr ago
Copy link