DEV Community

Cover image for Starting Java Programming series....
Sadiul Hakim
Sadiul Hakim

Posted on

Starting Java Programming series....

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

  1. Java is secure, robust , high-performant language
  2. It has rich features
  3. It is widely used in android and web application development
  4. Many desktop applications are created in java like Intelij,Netbeans ect.
  5. Java has strongest and securest database connectivity
  6. Java Spring framework is one of the most popular web frameworks
  7. Best for creating Enterprise applications
  8. Really good at cloud programming
  9. Java has a Large Community
  10. Java has Powerful Development Tools
  11. Java is pure multi-threading language etc.

Java has three platforms

  1. JavaSE
  2. JEE(Jakarta EE)
  3. 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
Enter fullscreen mode Exit fullscreen mode

You should get version numbers.

First program

Create a folder called java and go into it.

mkdir java
cd java
Enter fullscreen mode Exit fullscreen mode

Inside that folder create a class first.java

touch first.java
Enter fullscreen mode Exit fullscreen mode

Inside that file write these lines of code

class first{
        public static void main(String[] args){
                System.out.println("Hello World");
        }
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Now you should get a file called first.class

Now run this command to execute byte code

java first
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

and write

System.out.println("Hello, World!");
Enter fullscreen mode Exit fullscreen mode

You should get the message.

That's all for today.
I will continue this series.

Thank you ❤.

Top comments (0)