Learn with our youtube video – 7 Minutes
Windows User
1-Installation of java (java development kit)
Step 1:- Download the latest Java software (JDK) from oracle home site
->click this link (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
->Download the “Windows xxx Installer”
Step 2: Set the path – Path is required for using tools i.e. javac, java etc.,
For setting path permanently, perform these steps->
* Go to My computer/This PC ‘properties’ -> ‘advanced system settings’ -> ‘Environment Variables ‘-> ‘New’: it should be like following:
“Variable name: path
“Variable Value: (path of bin folder of JDK) i.e. C:\Program Files\Java\jdkX.X._XX\bin
Congratulations!
Linux User
Step 1- Go to Application -> Accessories -> Terminal.
Step 2-Type command as below..
sudo apt-get install openjdk-8-jdk
Note-change 8 in above line with current java version.
Step 3- For “JAVA_HOME” (Environment Variable) type command as shown below, in “Terminal” using your installation path…
(Note: the default path is as shown, but if you have install OpenJDK at other location then set that path.)
export JAVA_HOME = /usr/lib/jvm/java-8-openjdk
Step 4- For “PATH” (Environment Value) type command as shown below,
in “Terminal” using your installation path…
Note: the default path is as shown, but if you have install OpenJDK at other location then set that path.)
export PATH = $PATH:/usr/lib/jvm/java-X-openjdk/bin
You are done !! Now to check whether installation is done correctly, type java -version in the Terminal.
You will see that java is running on your machine.
Mac Users – How to Install JDK on macOS
Step 1: Download JDK
- Goto JDK (or Java SE) download site @ https://www.oracle.com/java/technologies/javase-downloads.html.
- Under “Oracle JDK”, click “JDK Download”.
- Download the “macOS DMG installer” (e.g,
jdk-15.0.{x}_osx-x64_bin.dmg
– about 172MB, where{x}
is a fast changing update number).
Step 2: Install JDK/JRE
- Double-click the downloaded Disk Image (DMG) file. Follow the screen instructions to install JDK/JRE.
- Eject the DMG file.
- To verify your installation, open a “Terminal” and issue these commands.
// Display the JDK version
javac -version javac 15.0.{x}
// Display the JRE version
java -version java version “15.0.{x}” .
// Display the location of Java Compiler which javac /usr/bin/javac
// Display the location of Java Runtime which java /usr/bin/java
2-Installation of IDE
There are many ide for development, but here are top in list, install any one-
(1)- Intelij
(2)- Eclipse
(3)- Netbeans
3- FIRST java program – (Shows a text in console(cMD))
Some common rules to follow-
1- Filename should be same as Class name (i.e FirstProg.java)
2- Class name must be start with Uppercase letter (i.e FirstProg (same as filename))
public class FirstProg {
public static void main(String[] args){
System.out.println("Yes It's working fine here");
}
}
public class FirstProg {
‘public’ Java modifier (Step – 8)
‘class’ is keyword (Step – 4)
‘FirstProg’ is user defined custom class name
‘{‘ is open curly bracket for group of code lines
public static void main(String[] args){
‘public’ Java modifier (Step – 8),
‘static’ Java modifier (Step – 8),
‘void’ is keyword which is used when we don’t return anything (String,int etc)
‘main’ is method name (JVM searches for method whose name is ‘main’ and executes it)
( ) after method name shows parameters
(String[] args) – we are passing String[] args as parameter to ‘main’ method,
String – It’s a class which is used as non primitive datatype in java, it’s used to support text data. (String a = ‘any text’)
String[] – [] is symbol used to show array, so String[] is array of Strings
i.e String[] b = [‘any text’, ‘some more’, ‘and more’]
args – It’s just a name declaration for String[] (just like ‘b’ in above example)-(you can use any name instead of args if you want to change)
System.out.println(“Yes It’s working fine here”);
System.out.println is way to print any text in console in java
System – System is class in java.lang package(folder)
out – It’s a object of PrintStream class inside System class
println – It’s a method declared in PrintStream class