Hello guys, I am Hakim. Today i am going to start my java series. In this series i will try to tech you basic of java programming language. This series is for beginners.
Java
Java is a high level programming language that runs on JVM. JVM means Java Virtual Machine. Java is a both compiled and interpreted language. When we compile .java file we get a .class file. That contains bytecode. Then we give that .class file to the jvm and jvm interpret that file. Java is platform independent language.
Why learn java
- Java is secure, robust , high-performant language
- It has rich features
- It is widely used in android and web application development
- Many desktop applications are created in java like Intelij,Netbeans ect.
- Java has strongest and securest database connectivity
- Java Spring framework is one of the most popular web frameworks
- Best for creating Enterprise applications
- Really good at cloud programming
- Java has a Large Community
- Java has Powerful Development Tools
- Java is pure multi-threading language etc.
Java has three platforms
- JavaSE
- JEE(Jakarta EE)
- JavaME
Installation
In this series i will use javaSE 17 and netbeans IDE.
To install java visit this site and download jdk and install.
Oracle JDK
Now what is jdk
JDK means Java Development Kit. It is a complete package of required tools and JRE(Java Runtime Environment) that are needed for writing and running java code.
I assume that you have install java. Now lets check the version
open terminal and run following code
javac --version
java --version
You should get version numbers.
First program
Create a folder called java and go into it.
mkdir java
cd java
Inside that folder create a class first.java
touch first.java
Inside that file write these lines of code
class first{
public static void main(String[] args){
System.out.println("Hello World");
}
}
You do not need to understand that code. Save file and open terminal in that folder.
To generate bytecode we need to compile .java file. To compile run this command
javac first.java
Now you should get a file called first.class
Now run this command to execute byte code
java first
You should get the message Hello World
.
Jshell
Jshell is new integration in java 9 version. It helps you write code in terminal. You do not need to write whole class. To run jshell open terminal and give this command
jshell
and write
System.out.println("Hello, World!");
You should get the message.
That's all for today.
I will continue this series.
Thank you ❤.
Top comments (0)