In this blog let us see what is java and why is it used?
What is Java?
- Java is a set of computer software and specifications developed by James Gosling, in the year 1996.
- Java is an open source free and efficient programming which build the steps for coding in android.
- It is used in the development of mobile applications and deploy it in cross-platform computing environment.
Components of Java:
- For the java program you basically need two components:
- JRE: Java Run time environment will enable you to run the program in your system but not develop.
- JDK: Java Development kit is the key component used for the development of applications.
- And it is one of the technologies from the three core technologies JVM (Java Virtual Machine) and JRE (Java Run time environment) which is very much important for the java compiler.
- The link given below will enable us to install jdk and jre:
- https://www.oracle.com/java/technologies/javase/javase7-archive-downloads.html
- And after the installation of jdk and jre you need to install eclipse or vs code which will enable you to program on a good ide.
- Once you have completed installing jre and jdk you are now ready to start coding in java.
How Java works?
- Install Java on your VS Code so that you can start writing your first code.
- Java files are saved with a .java extension.
- If you are to compile the code from the terminal you need to compile it using the command javac Main.java.
- And to run your code once after compilation there will be .class created so now to run your code you need to enter the command java Main.
Hello World Program:
- The basic terminologies to be included:
- public class: Public class in java means that a person can access the code or application publicly and can also modify the program until unless a code is declared as the final one.
- Public static void main: Public static void main means that you declare a main method within the Java application. It is the core point wherein it call any variable or data type.
- And will also not return to any values and accepts any parameters for complex command lines.
- String[] args: It stores Java command line arguments and is an array of type java. string class Here, the name of the String array is args but it is not fixed and user can use any name in place of it.
- Out. println is a Java statement that prints the argument passed, into the System. out which is generally stdout. System – is a final class in java.
- Now let us write the basic java program: (Hello World)
public class Main {
public static void main(String[] args){
System.out.println("Hello World");
}
}
Java setup for Mac:
- For setting up Java in mac the link given below can be followed.
- https://java.com/en/download/faq/java_mac.xml
- And the steps to be followed are:
- Step 1:
Step 2:
Step 3:
Step 4:
For JDK link is: : https://www.oracle.com/java/technolog…
For Setting Up Java in Windows:
The link for downloading JRE is : https://www.java.com/download/ie_manu…
- The steps to be followed are:
- Step 1:
Step 2:
Step 3: