JAVA Programming language - coderz.py https://coderzpy.com Keep Coding Keep Cheering! Wed, 27 Apr 2022 16:59:42 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://coderzpy.com/wp-content/uploads/2022/08/cropped-image1-1-32x32.jpg JAVA Programming language - coderz.py https://coderzpy.com 32 32 What is Java programming language https://coderzpy.com/what-is-java-programming-language/ https://coderzpy.com/what-is-java-programming-language/#respond Tue, 12 Apr 2022 15:42:30 +0000 http://coderzpy.com/?p=1390 Introduction to Java programming language In 1995, James Gosling founded Sun Microsystems Inc, which was later acquired by Oracle Corporation. ...

The post What is Java programming language first appeared on coderz.py.

]]>
Introduction to Java programming language

In 1995, James Gosling founded Sun Microsystems Inc, which was later acquired by Oracle Corporation. It’s a straightforward programming language. Java makes programming easy to write, compile, and debug. It aids in the development of reusable code and modular programs.

Java is a class-based, object-oriented programming language with a focus on minimizing implementation dependencies.

A compiled general-purpose programming language designed for developers to write once and run anywhere(WORA). All platforms that support Java can run Java code.

Java programs are compiled into byte code that can be run on any Java Virtual Machine. Java’s syntax is similar to that of C/C++.

Because it has a runtime environment (JRE) and API, Java is a platform-independent language. A platform, in this context, refers to the hardware or software environment in which an application runs.

Java programs are compiled into byte code, which is machine-independent. The JVM is used to execute this byte code (Java Virtual Machine).

JAVA is the name of the Java programming language. Why?


The team decided to rename it after OAK and suggested words included Silk, Jolt, revolutionary, DNA, dynamic, and others. These names were all simple to pronounce and spell, but they all wanted to capture the essence of technology. According to James Gosling, Java was one of the top names, along with Silk, and because it was a unique name, most people preferred it.

Java is the name of an Indonesian island where the first coffee (also known as Java coffee) was grown. And while having coffee near his office, James Gosling came up with this name. It’s worth noting that Java is merely a name, not an acronym.

Note: also read about the C Programming Language

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post What is Java programming language first appeared on coderz.py.

]]>
https://coderzpy.com/what-is-java-programming-language/feed/ 0
Features of JAVA programing language https://coderzpy.com/features-of-java-programing-language/ https://coderzpy.com/features-of-java-programing-language/#respond Thu, 14 Apr 2022 16:46:00 +0000 http://coderzpy.com/?p=1396 There were numerous characteristics that contributed to the final form of this outstanding language. The major features of Java programming: ...

The post Features of JAVA programing language first appeared on coderz.py.

]]>
There were numerous characteristics that contributed to the final form of this outstanding language.

The major features of Java programming:
  1. Object-Oriented: Everything in Java is an Object. Because it is based on the object model, Java can be easily extended.
  2. Simple: Java was created with the goal of being simple to learn. It should be simple to master if you understand the fundamental concepts of OOP Java.
  3. Secure: Java’s secure feature enables the creation of virus-free and tamper-proof systems. Public-key encryption is used in authentication techniques.
  4. Platform-independent: Unlike many other programming languages, such as C and C++, Java is compiled into platform-independent byte code rather than platform-specific machine code. This byte code is distributed over the internet and is interpreted by the Virtual Machine (JVM) on the platform on which it is run.
  5. Architecture-neutral: With the presence of the Java runtime system, the Java compiler generates an architecture-neutral object file format, which makes the compiled code executable on a wide range of processors.
  6. Portable: Java is portable because it is architecture-neutral and has no implementation-dependent aspects of the specification. The Java compiler is written in ANSI C, which is a POSIX subset, with a clean portability boundary.
  7. Robust: Java focuses on compile-time error checking and runtime error checking in order to eliminate error-prone situations.
  8. Multithreaded: It is possible to write programs that can perform multiple tasks at the same time using Java’s multithreaded feature. Developers can use this design feature to create interactive applications that run smoothly.
  9. Interpreted: Java byte code that is interpreted is converted to native machine instructions on the fly and is not saved. Because linking is an incremental and lightweight process, the development process is more rapid and analytical.
  10. High-Efficiency: Java achieves high performance through the use of Just-In-Time compilers.
  11. Distributed: Java was created with the internet’s distributed environment in mind.
  12. Dynamic: Because it is designed to adapt to a changing environment, Java is considered more dynamic than C or C++. Java programs can store a large amount of run-time data that can be used to verify and resolve object accesses in real-time.
JAVA 11’s New Features

Java 11 is a recommended long-term support (LTS) version of Java that includes a number of useful features. These features include both new and improved aspects of the existing topic. Just skim through them quickly; we’ll get into more detail later:

  • includes Unicode 10.0.0 support
  • Standardization of the HTTP Client has been achieved.
  • Compiler Threads Are Allotted Slowly
  • Locale data has been updated to Unicode CLDR v33.
  • 331 JEP Heap Profiling with Low Overhead
  • JEP 181 Adds Brainpool EC Support to Nest-Based Access Control (RFC 5639)
  • KeyStore Mechanisms Have Been Improved
  • Transport Layer Security (TLS) 1.3, JEP 332
  • Launch Single-File Source-Code Programs (JEP 330)

Note: also read about the What is Java programming language

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Features of JAVA programing language first appeared on coderz.py.

]]>
https://coderzpy.com/features-of-java-programing-language/feed/ 0
Setting CLASSPATH in Java https://coderzpy.com/setting-classpath-in-java/ https://coderzpy.com/setting-classpath-in-java/#respond Thu, 14 Apr 2022 17:28:22 +0000 http://coderzpy.com/?p=1398 In Java, you can set the CLASSPATH variable. CLASSPATH: Application ClassLoader uses CLASSPATH as an environment variable to locate and ...

The post Setting CLASSPATH in Java first appeared on coderz.py.

]]>
In Java, you can set the CLASSPATH variable.

CLASSPATH:

Application ClassLoader uses CLASSPATH as an environment variable to locate and load .class files. The CLASSPATH specifies the location of third-party and user-defined classes that are not extensions or components of the Java platform. When setting the CLASSPATH, make sure to include all directories that contain .class files and JAR files.

If the following conditions apply, you must set the CLASSPATH:

  • You must load a class that isn’t in the current directory or any of its subdirectories.
  • You need to load a class that isn’t in the extensions mechanism’s specified location.

A dot is the default value for CLASSPATH (.). It refers to the only directory that is currently being searched. When you set the CLASSPATH variable or use the -classpath command, the default value of CLASSPATH takes precedence (for short -cp). If you want to include the current directory in the search path, add a dot (.) to the new setting.

There are two ways to ways to set CLASSPATH: through Command Prompt or by setting Environment Variable.

Let’s see how to set CLASSPATH of MySQL database:

Step 1: Click on the Windows button and choose Control Panel. Select System.

How to Set CLASSPATH in Java

Step 2: Click on Advanced System Settings.

How to Set CLASSPATH in Java

Step 3: A dialog box will open. Click on Environment Variables.

How to Set CLASSPATH in Java

Step 4: If the CLASSPATH already exists in System Variables, click on the Edit button then put a semicolon (;) at the end. Paste the Path of MySQL-Connector Java.jar file.

If the CLASSPATH doesn’t exist in System Variables, then click on the New button and type Variable name as CLASSPATH and Variable value as C:\Program Files\Java\jre1.8\MySQL-Connector Java.jar;.;

Remember: Put ;.; at the end of the CLASSPATH.

How to Set CLASSPATH in Java

How to Set CLASSPATH in Windows Using Command Prompt

Type the following command in your Command Prompt and press enter

set CLASSPATH=%CLASSPATH%;C:\Program Files\Java\jre1.8\rt.jar;

The set command is an internal DOS command that allows the user to change the variable value in the above command. CLASSPATH is the name of a variable. The variable enclosed in the percent sign (%) is already present in the environment. The semicolon is a separator, and the PATH to the rt.jar file is after the (;).

Note: also read about the What is Java programming language

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Setting CLASSPATH in Java first appeared on coderz.py.

]]>
https://coderzpy.com/setting-classpath-in-java/feed/ 0
Byte Code in Java https://coderzpy.com/byte-code-in-java/ https://coderzpy.com/byte-code-in-java/#respond Fri, 15 Apr 2022 11:36:43 +0000 http://coderzpy.com/?p=1400 Byte Code: The Java byte code is a machine instruction for a Java processor chip called Java Virtual Machine. The ...

The post Byte Code in Java first appeared on coderz.py.

]]>
Byte Code:

The Java byte code is a machine instruction for a Java processor chip called Java Virtual Machine. The byte code is independent of the computer system it has to run, i.e, Java programs are compiled, and their byte codes are produced. The byte codes are always the same irrespective of the computer system they are to execute upon.

To understand the byte code, one must be clear about the compilation process.

Ordinary Compilation process:
  • The program or the source code written by a programmer is usually called the source code.
  • This source code needs to be converted into a machine language code, which a computer can easily understand.
  • The process of converting a source code into machine language code is called compilation.
  • The converted machine code depends a lot on the platform it is executing upon, i.e, the resultant machine code is called native executable code.
  • Instead of using a compiler, one can use an interpreter, which translates the code instruction-by-instruction.

here, the first diagram is the ordinary compilation process, whereas, the second diagram represents Java compilation producing the bytecode.

Java Compilation:
  • Contrary to ordinary compilation, the Java compiler does not produce native executable code for a particular machine. Instead, it produces a special format called byte code.
  • The Java byte code looks a lot like machine language, but unlike machine language, Java byte code is the same on every platform.
  • However, the Java programs that have been compiled into byte code still need an interpreter to execute them on any given platform.
  • The interpreter reads the byte code and translates it into the native language of the host machine.
  • Since byte code is completely platform-independent, only a few native libraries need to be ported t get Java to run on a new computer or operating system.

Note: also read about the Setting CLASSPATH in Java

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Byte Code in Java first appeared on coderz.py.

]]>
https://coderzpy.com/byte-code-in-java/feed/ 0
Java Virtual Machine(JVM) https://coderzpy.com/java-virtual-machinejvm/ https://coderzpy.com/java-virtual-machinejvm/#respond Sun, 17 Apr 2022 14:30:14 +0000 http://coderzpy.com/?p=1403 Programs written in Java are compiled into Java Byte code, which is then interpreted by a special Java Interpreter for ...

The post Java Virtual Machine(JVM) first appeared on coderz.py.

]]>
Programs written in Java are compiled into Java Byte code, which is then interpreted by a special Java Interpreter for a specific platform. Actually, this Java interpreter is known as the Java Virtual Machine(JVM). The machine language for the Java Virtual Machine is called Java byte code.

The Java interpreter, when run on any machine, looks and acts like a “virtual” processor chip, hence the name JVM. The Java Virtual Machine is a software abstraction that runs on top of existing processors. It shields Java applications from the underlying operating system. The Java Virtual Machine is a software or hardware implementation of the Java Virtual Machine.

The Java Platform is made up of the JVM and Java APIs. The Java API (Application Programming Interface) are compiled code libraries that you can use in your programs. In other words, the Java API is a set of functions and variables that programmers can use in their programs.

What it does

The JVM performs following

  • Loads code
  • Verifies code
  • Executes code
  • Provides runtime environment

JVM provides definitions for the:

  • Memory area
  • Class file format
  • Register set
  • Garbage-collected heap
  • Fatal error reporting etc.
JVM Architecture

Let’s understand the internal architecture of JVM. It contains a class loader, memory area, execution engine, etc.

Java Virtual Machine(JVM)

Note: also read about the What is Java programming language

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Java Virtual Machine(JVM) first appeared on coderz.py.

]]>
https://coderzpy.com/java-virtual-machinejvm/feed/ 0
JDK vs JRE vs JVM https://coderzpy.com/jdk-vs-jre-vs-jvm/ https://coderzpy.com/jdk-vs-jre-vs-jvm/#respond Tue, 19 Apr 2022 17:31:20 +0000 http://coderzpy.com/?p=1406 Let us now compare Java Virtual Machine, JRE, and JDK. The following are the key distinctions between JDK, JRE, and ...

The post JDK vs JRE vs JVM first appeared on coderz.py.

]]>
Let us now compare Java Virtual Machine, JRE, and JDK. The following are the key distinctions between JDK, JRE, and JVM.

JVM JDK JRE
Sr. No. KeyJDKJREJVM
1DefinitionThe Java Development Kit (JDK) is a software development kit for creating Java applications. JDK includes a number of development tools in addition to JRE (compilers, JavaDoc, Java Debugger etc.).JRE (Java Runtime Environment) is the JVM implementation and is defined as a software package that includes Java class libraries, a Java Virtual Machine (JVM), and other components for running Java applications.JVM (Java Virtual Machine) is a platform-independent abstract machine with three concepts: specification, a document describing JVM implementation requirements, implementation, a computer program that meets JVM requirements, and instance, an implementation that executes Java byte code.
2Prime functionalityJDK is a programming language that is primarily used for code execution and development.JRE, on the other hand, is primarily responsible for creating the environment in which code can be executed.JVM, on the other hand, specifies all implementations and is responsible for providing them to JRE.
3Platform IndependenceJDK is platform-dependent, which means that different JDKs are required for different platforms.JRE, like JDK, is platform-dependent.JVM is platform-independent.
4ToolsBecause JDK is in charge of primary development, it includes tools for creating, debugging, and monitoring Java applications.JRE, on the other hand, does not include tools like a compiler or a debugger. Rather, it contains the class libraries and other supporting files required by JVM to run the program.Software development tools are not included in the JVM.
5ImplementationJDK = Java Runtime Environment (JRE) + Development toolsJRE = Java Virtual Machine (JVM) + Libraries to run the applicationJVM = Only Runtime environment for executing the Java byte code.

Note: also read about the Byte Code in Java

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post JDK vs JRE vs JVM first appeared on coderz.py.

]]>
https://coderzpy.com/jdk-vs-jre-vs-jvm/feed/ 0
Simple Hello World Program https://coderzpy.com/simple-hello-world-program/ https://coderzpy.com/simple-hello-world-program/#respond Tue, 19 Apr 2022 18:09:19 +0000 http://coderzpy.com/?p=1411 Requirement for Java Hello World Program: Install the JDK if you don’t have installed it, download the JDK and install it. Set ...

The post Simple Hello World Program first appeared on coderz.py.

]]>
Requirement for Java Hello World Program:
Hello World Example:
class Hello{  
    public static void main(String args[]){  
     System.out.println("Hello World! Coderzpy");  
    }  
}  

Save the above file as Hello.java.

In the terminal:

To compile:javac Hello.java
To execute:java Hello
Output:
Hello World! Coderzpy
Parameters used:

Let’s look at what class, public, static, void, main, String[], and System.out.println mean ().

  • In Java, the class keyword is used to declare a class.
  • The visibility is represented by the public keyword, which is an access modifier. It means that it is visible to everyone.
  • static is a keyword. Any method that is declared as static is referred to as a static method. The main advantage of the static method is that it does not require the creation of an object to use. Because the main() method is executed by the JVM, there is no need to create an object to call it. As a result, it conserves memory.
  • The method’s return type is void. It indicates that it does not return any information.
  • The program’s starting point is represented by main.
  • The command line argument is String[] args or String args[]. We’ll go over it in the next section.
  • To print a statement, use System.out.println(). System is a class, out is a PrintStream class object, and println() is a PrintStream class method. In the following section, we’ll look at how the System.out.println() statement works internally.
Compilation Flow:

The Java compiler converts source code into byte code when we compile a Java program with the javac tool.

hello world

Note: We can also use other editors like the eclipse(https://www.eclipse.org/downloads/), also read about the JDK vs JRE vs JVM

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Simple Hello World Program first appeared on coderz.py.

]]>
https://coderzpy.com/simple-hello-world-program/feed/ 0
Token and keywords https://coderzpy.com/token-and-keywords/ https://coderzpy.com/token-and-keywords/#respond Wed, 20 Apr 2022 23:32:54 +0000 http://coderzpy.com/?p=1416 Token The smallest individual unit in a program is known as a token. In fact, every unit that makes a ...

The post Token and keywords first appeared on coderz.py.

]]>
Token

The smallest individual unit in a program is known as a token. In fact, every unit that makes a sentence is a token.

Java has the following token:

  • Keywords
  • Identifiers
  • Literals
  • Punctuators
  • Operators
Keywords

Keywords are the words that convey a special meaning to the language compiler. These are reserved for special purposes and must not be used as normal identifier names.

The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers:

abstractdefaultifprivatethis
booleandoimplementsprotectedthrow
breakdoubleimportpublicthrows
byteelseinstanceofreturntransient
caseextendsintshorttry
catchfinalinterfacestaticvoid
charfinallylongstrictfpvolatile
classfloatnativesuperwhile
constfornewswitch
continuegotopackagesynchronized

The keywords const and goto are reserved, even though they are currently not in use. This may allow a Java compiler to produce better error messages if these Java Keywords incorrectly appear in programs.

While true and false might appear to be keywords, they are technically boolean literals. Similarly, while null might appear to be a keyword, it is technically the null literal. Thus true, false and null are not keywords but reserved words.

Note: also read about the Simple Hello World Program

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Token and keywords first appeared on coderz.py.

]]>
https://coderzpy.com/token-and-keywords/feed/ 0
Identifiers https://coderzpy.com/identifiers/ https://coderzpy.com/identifiers/#respond Thu, 21 Apr 2022 00:12:51 +0000 http://coderzpy.com/?p=1418 Identifiers are fundamental building blocks of a program and are used as the general terminology for the names given to ...

The post Identifiers first appeared on coderz.py.

]]>
Identifiers are fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program viz. variables, objects, classes, functions, arrays, etc.

Identifier forming rules of Java state the following:
  • Identifiers can have alphabets, digits, and underscore and dollar sign characters.
  • They must not be a keyword or boolean literal or null literal.
  • They must not begin with a digit.
  • Furthermore, they can be of any length.
  • Java is case-sensitive, i.e, upper-case letters and lower-case letters are treated differently.

The following are some valid identifiers:

MyFile    A_to_Z
MYFILE    $1_abc
_CHK      file341

The following are some invalid identifiers:

DATA-REC    contains special character(-)
29fgt       Starting with a digit
break       reserved keyword
My.File     contains special character
Identifier naming conventions:

While making identifiers name, certain conventions are followed:

  • The name of public methods and instance variables should begin with a lowercase letter.
  • For names having multiple words, the second and subsequent words’ beginning character is made capital to enhance readability.
  • Private and local variables should use lowercase letters.
  • The class names and interface names begin with an upper case letter.
  • The constants should be named using capital letters and underscore.

Note: also read about the Token and keywords

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Identifiers first appeared on coderz.py.

]]>
https://coderzpy.com/identifiers/feed/ 0
Literals in Java https://coderzpy.com/literals-in-java/ https://coderzpy.com/literals-in-java/#respond Thu, 21 Apr 2022 01:00:20 +0000 http://coderzpy.com/?p=1420 Literals(often referred to as constants) are data items that are fixed data values. Java allows several kinds of literal: integer-literal ...

The post Literals in Java first appeared on coderz.py.

]]>
Literals(often referred to as constants) are data items that are fixed data values. Java allows several kinds of literal:

  • integer-literal
  • floating-literal
  • boolean-literal
  • character-literal
  • string-literal
  • null-literal
Integer Literal:

Integer Literals are whole numbers without any fractional part. The method of writing integer constants has been specified in the following rule:

An integer constant must have at least one digit and must not contain any decimal point. It may contain either a + or – sign. A number with no sign is assumed to be positive. Commas cannot appear in an integer constant.

Java allows three types of integer literals:

  • Decimal(base 10)
  • Octal(base 8)
  • Hexadecimal(base 16)
Floating Literal:

Floating literals are also called real literals.

Real literals are numbers having fractional parts. These may be written in one of the two forms called fractional form to the exponent form.

The rule for writing a real constant in fractional form is given below:

A real literal in the fractional form must have at least one digit before a decimal point and at least one digit after the decimal point. It may also have either a + or – sign preceding it. A real literal with no sign is assumed to be positive. For instance, 2.0, 17.5, -13.0, etc.

Boolean Literal:

The boolean type has two values, represented by the literals true and false, formed from ASCII letters.

A boolean literal is always of two types, boolean. It is either boolean value true or boolean value false.

Character Literals:

A character literal is one character enclosed in single quotes, as in ‘z’. The rule for writing character constant is given below:

A character literal in Java must contain one character and must be enclosed in single quotation marks.

Note: also read about the Token and keywords

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

The post Literals in Java first appeared on coderz.py.

]]>
https://coderzpy.com/literals-in-java/feed/ 0