DEV Community

R.Shobika CSE
R.Shobika CSE

Posted on

JAVA INTRO

JAVA:

  • Java is a high level programming language.

  • Java is a secure language

  • It is a statically type programming language

  • It is a case sensetive.

  • First Java was developed in 1991 in the name of Oak then in 1995 Oak change into Java
    -Java was developed by James Gosling

JAVA ACHITECTURE

Java does not compile the whole program to the machine code (0,1) there is a two part in compilation

1st part -> Java programming file Translate into class file it is called as a byte code It was translate by a Java Development Kit [JDK] . This is a platform independent.

2nd part -> the byte code is translate into a binary values(0,1)[machine code] .It was translate by JIT [ Just In Time] compiler basically its a interpreter type , It does not translate directly into the machine code firstly it will translate byte code into a Java Virtual Machine [JVM]

The entire Process is a Java RunTime Environment .

JDK
JDK (Java Development Kit) is a software package used to develop and run Java applications. It provides all the necessary tools required for writing, compiling, debugging, and executing Java programs. JDK is mainly used by Java developers to create Java-based applications.

JIT
The JIT or Just-In-Time compiler is an essential part of the JRE (Java Runtime Environment), that is responsible for performance optimization of java based applications during run time. The compiler is one of the key aspects in deciding the performance of an application for both parties i.e. the end-user and the application developer.

JVM
The Java Virtual Machine (JVM) is an abstract machine that provides the runtime environment for executing Java bytecode. It is a part of the Java Runtime Environment (JRE) and is responsible for loading, verifying, and executing Java class files.

JRE
Java Runtime Environment (JRE) is a software package that provides the environment required to run Java applications. It contains the Java Virtual Machine (JVM), core class libraries, and supporting files needed to execute Java bytecode. JRE is a part of the Java Development Kit (JDK) and is responsible for running Java programs on different platforms.

HOW TO CREATE AND EXECUTE THE JAVA FILE??

1st create the java file file name is "Sample.java"

public class Sample{
public static void main (String[], args){
System.out.println("HELLO WORLD!!!");
Enter fullscreen mode Exit fullscreen mode

the file name and class name should be same and java is a case sensitive

2nd execute the file the commands are

javac Sample.java   ------> java file convert into a class file 
java Sample         ------> execute the program 
Enter fullscreen mode Exit fullscreen mode

output:
HELLO WORLD!!!

TASK: error making


class Sample {
    public static void main(String[] args) {
        System.out.println("HELLO WORLD!!!")
    }
}

o/p:
Main.java:6: error: ';' expected
        System.out.println("HELLO WORLD!!!")
                                            ^
1 error


class Sample {
    public static void main(string[] args) {
        System.out.println("HELLO WORLD!!!")
    }
}

o/p:
ERROR!
Main.java:5: error: cannot find symbol
    public static void main(string[] args) {
                            ^
  symbol:   class string
  location: class Main
1 error

class Sample {
    public Static Void Main(String[] args) {
        System.out.println("HELLO WORLD!!!");
    }
}

o/p:
ERROR!
/tmp/EnWS8Elbz1/Main.java:5: error: ';' expected
    public Static Void Main(String[] args) {
                      ^
ERROR!
/tmp/EnWS8Elbz1/Main.java:5: error: invalid method declaration; return type required
    public Static Void Main(String[] args) {
                       ^
2 errors
ERROR!
error: compilation failed


class Sample {
     static void main(String[] args) {
        System.out.println("HELLO WORLD!!!");
    }
}

o/p:
ERROR!
error: can't find main(String[]) method in class: Sample

class Sample {
    public static void main(String[] args) {
        system.out.println("HELLO WORLD!!!");
    }
}
o/p:
ERROR!
/tmp/Ldf0kuboP4/Main.java:6: error: package system does not exist
        system.out.println("HELLO WORLD!!!");
              ^
1 error
ERROR!
error: compilation failed

class Sample {
    public static void main(String[] args) {
        System.println("HELLO WORLD!!!");
    }
}

o/p:
ERROR!
/tmp/2TXFdsDVof/Main.java:6: error: cannot find symbol
        System.println("HELLO WORLD!!!");
              ^
  symbol:   method println(String)
  location: class System
1 error
ERROR!
error: compilation failed


class Sample {
    public static void main(String[]) {
        System.out.println("HELLO WORLD!!!");
    }
}

o/p:
ERROR!
/tmp/UMTKDZ87fM/Main.java:5: error: <identifier> expected
    public static void main(String[]) {
                                    ^
1 error
ERROR!
error: compilation failed

class Sample {
    public static void main(String args) {
        System.out.println("HELLO WORLD!!!");
    }
}
o/p:
ERROR!
error: can't find main(String[]) method in class: Sample

class Sample {
    public static void main(String[] args) {
        System.out.println("HELLO WORLD!!!");

}
o/p:
ERROR!
/tmp/dDrMpwFDDr/Main.java:8: error: reached end of file while parsing
}
 ^
1 error
ERROR!
error: compilation failed

Sample {
    public static void main(String[] args) {
        System.out.println("HELLO WORLD!!!");
    }
}
o/p:
ERROR!
/tmp/51yfKuJfaN/Main.java:4: error: class, interface, enum, or record expected
Sample {
^
ERROR!
/tmp/51yfKuJfaN/Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
    public static void main(String[] args) {
                  ^
  (use --enable-preview to enable unnamed classes)
ERROR!
/tmp/51yfKuJfaN/Main.java:8: error: class, interface, enum, or record expected
}
^
3 errors
ERROR!
error: compilation failed

Enter fullscreen mode Exit fullscreen mode

Top comments (0)