Java Programming Under A Bluesky: learn from basics now part-1

Java Programming

INTRODUCTION:Java Programming

Java Programming is one of the most popular and widely used programming languages.Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc). The Java codes are first compiled into byte code (machine-independent code). Then the byte code runs on Java Virtual Machine (JVM) regardless of the underlying architecture.

Java syntax is similar to C/C++. But Java does not provide low-level programming functionalities like pointers. Also, Java codes are always written in the form of classes and objects. It is used in all kinds of applications like Mobile Applications (Android is Java-based), desktop applications, web applications, client-server applications, enterprise applications, and many more.

Java Programming

comparison: Java Programming

When compared with C++, Java codes are generally more maintainable because Java does not allow many things which may lead to bad/inefficient programming if used incorrectly. For example, non-primitives are always references in Java. So we cannot pass large objects (like we can do in C++) to functions, we always pass references in Java. One more example, since there are no pointers, bad memory access is also not possible.

When compared with Python, Java kind of fits between C++ and Python. The programs are written in Java typically run faster than corresponding Python programs and slower than C++. Like C++, Java does static type checking, but Python does not.

Simple Hello World Program: Java Programming

// A Java program to print "Hello World" 
public class GFG { 
    public static void main(String args[]) 
        System.out.println("Hello World"); 

OUTPUT: Java Programming

Hello World


Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture.

The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client–server web applications, with a reported 9 million developers.

Also visit….

HISTORY: Java Programming

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling’s office.

Later the project went by the name Green and was finally renamed Java, from Java coffee, a type of coffee from Indonesia. Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar.

Java Programming
James Gosling, the creator of Java, in 2008

Principles: Java Programming

There were five primary goals in the creation of the Java language:

  1. It must be simple, object-oriented, and familiar.
  2. It must be robust and secure.
  3. It must be architecture-neutral and portable.
  4. It must execute with high performance.
  5. It must be interpreted, threaded, and dynamic.


Major release versions of Java, along with their release dates:

JDK Beta1995
JDK 1.0January 23, 1996[40]
JDK 1.1February 19, 1997
J2SE 1.2December 8, 1998
J2SE 1.3May 8, 2000
J2SE 1.4February 6, 2002
J2SE 5.0September 30, 2004
Java SE 6December 11, 2006
Java SE 7July 28, 2011
Java SE 8 (LTS)March 18, 2014
Java SE 9September 21, 2017
Java SE 10March 20, 2018
Java SE 11 (LTS)September 25, 2018[41]
Java SE 12March 19, 2019
Java SE 13September 17, 2019
Java SE 14March 17, 2020
Java SE 15September 15, 2020[42]
Java SE 16March 16, 2021
Java SE 17 (LTS)September 14, 2021
Java SE 18March 22, 2022
Java SE 19September 20, 2022

Syntax: Java Programming

The syntax of Java is largely influenced by C++ and C. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language. All code is written inside classes, and every data item is an object, with the exception of the primitive data types, (i.e. integers, floating-point numbers, boolean values, and characters), which are not objects for performance reasons. Java reuses some popular aspects of C++ (such as the printf method).

Hello world example: Java Programming

The traditional Hello world program can be written in Java as:

class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); // Prints the string to the console. } }


Java applets were programs that were embedded in other applications, typically in a Web page displayed in a web browser. The Java applet API is now deprecated since Java 9 in 2017.


Java servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. Servlets are server-side Java EE components that generate responses to requests from clients. Most of the time, this means generating HTML pages in response to HTTP requests, although there are a number of other standard servlet classes available, for example for WebSocket communication.

The Java servlet API has to some extent been superseded (but still used under the hood) by two standard Java technologies for web services:

  • the Java API for RESTful Web Services (JAX-RS 2.0) useful for AJAX, JSON and REST services, and
  • the Java API for XML Web Services (JAX-WS) useful for SOAP Web Services.
JavaServer Pages
Java Programming
Java Programming

JavaServer Pages (JSP) are server-side Java EE components that generate responses, typically HTML pages, to HTTP requests from clients. JSPs embed Java code in an HTML page by using the special delimiters <% and %>. A JSP is compiled to a Java servlet, a Java application in its own right, the first time it is accessed. After that, the generated servlet creates the response.

Swing application

Swing is a graphical user interface library for the Java SE platform. It is possible to specify a different look and feel through the pluggable look and feel system of Swing. Clones of Windows, GTK+, and Motif are supplied by Sun. Apple also provides an Aqua look and feel for macOS. Where prior implementations of these looks and feels may have been considered lacking, Swing in Java SE 6 addresses this problem by using more native GUI widget drawing routines of the underlying platforms.

Basic Concepts of Java Programming

Java programming is based on several fundamental concepts, including:

  1. Object-oriented programming: Java is an object-oriented programming language, which means that it is based on the concept of objects. Objects have properties (or attributes) and methods (or behaviors) that define their behavior.

  2. Platform independence: Java is platform-independent, which means that it can run on any platform (e.g., Windows, Linux, macOS) that has a Java Virtual Machine (JVM) installed.

  3. Garbage collection: Java has automatic memory management, which means that it automatically manages memory allocation and deallocation. This is done through a process called garbage collection.

Key Features of Java Programming

Some of the key features of Java programming include:

  1. Simple syntax: Java has a simple and easy-to-learn syntax that makes it accessible to beginner programmers.

  2. Object-oriented: Java is a fully object-oriented language, which means that it is based on the concept of objects.

  3. Platform-independent: Java is platform-independent, which means that it can run on any platform that has a JVM installed.

  4. Multi-threaded: Java supports multi-threading, which means that it can run multiple threads of execution simultaneously.

  5. Garbage collection: Java has automatic memory management, which means that it automatically manages memory allocation and deallocation.

Applications of Java Programming

Java programming is used in a wide range of applications, including:

  1. Web development: Java is widely used in web development for creating dynamic web pages, web applications, and web services.

  2. Mobile app development: Java is used in mobile app development for creating Android applications.

  3. Game development: Java is used in game development for creating both desktop and mobile games.

  4. Enterprise development: Java is used in enterprise development for creating large-scale applications that are used in businesses and organizations.

Advanced Concepts of Java Programming

Java programming also includes advanced concepts that allow developers to create more complex and sophisticated applications. Some of these concepts include:

  1. Generics: Java’s generics feature allows developers to write generic code that can work with any data type. This helps to reduce code duplication and improve code reusability.

  2. Lambda expressions: Java’s lambda expressions allow developers to write more concise and expressive code for handling events and callbacks.

  3. Streams: Java’s streams feature allows developers to process collections of data in a more efficient and concise way.

  4. Annotations: Java’s annotations feature allows developers to add metadata to code that can be used for documentation or to control the behavior of code.

Frameworks and Libraries for Java Programming

Java programming also has a wide range of frameworks and libraries that can be used to simplify the development process and speed up the time to market. Some of the popular frameworks and libraries for Java programming include:

  1. Spring Framework: Spring is a popular framework for building web applications and enterprise applications.

  2. Hibernate: Hibernate is a popular object-relational mapping (ORM) framework that allows developers to map Java objects to database tables.

  3. Apache Struts: Apache Struts is a popular framework for building web applications using the Model-View-Controller (MVC) architecture.

  4. JUnit: JUnit is a popular testing framework for Java that allows developers to write and run automated tests for their code.

  5. Apache Maven: Apache Maven is a popular build automation tool for Java that allows developers to manage dependencies and build their applications.

Best Practices for Java Programming

To ensure that your Java code is reliable, maintainable, and efficient, it’s important to follow some best practices. Here are some tips for writing high-quality Java code:

  1. Follow naming conventions: Use consistent and descriptive names for classes, variables, and methods to make your code more readable.

  2. Use comments: Add comments to explain what your code is doing and why it’s doing it.

  3. Write clear and concise code: Avoid using complex or unnecessary code that can make your code difficult to understand.

  4. Use exception handling: Use try-catch blocks to handle exceptions and errors in your code.

  5. Use design patterns: Use established design patterns to solve common problems and improve the architecture of your code.

  6. Test your code: Use automated testing frameworks like JUnit to test your code and ensure that it’s working correctly.

Tools for Java Programming

There are many tools available for Java programming that can help developers to write better code, improve productivity, and streamline their development workflow. Here are some of the most popular tools for Java programming:

  1. Integrated Development Environments (IDEs): IDEs like Eclipse, IntelliJ IDEA, and NetBeans provide a complete development environment for Java programming, including code editors, debugging tools, and support for version control systems.

  2. Build Automation Tools: Build automation tools like Apache Maven and Gradle help automate the build process for Java applications, including managing dependencies, compiling code, and creating executable files.

  3. Code Analysis Tools: Code analysis tools like SonarQube and FindBugs help identify potential bugs and vulnerabilities in Java code, and suggest ways to improve code quality.

  4. Testing Frameworks: Testing frameworks like JUnit and TestNG help developers to write automated tests for their Java code, ensuring that the code works as expected and catches any regressions.

Java Frameworks

Java programming offers a wide range of frameworks that can help developers to build scalable and efficient applications. Here are some of the most popular frameworks for Java programming:

  1. Spring Framework: Spring is one of the most popular frameworks for Java programming, offering a wide range of tools and features for building web applications, including Spring Boot, Spring MVC, and Spring Data.

  2. Hibernate: Hibernate is a popular framework for object-relational mapping (ORM) in Java, allowing developers to easily map Java objects to relational databases.

  3. Struts: Struts is a framework for building web applications that provides a Model-View-Controller (MVC) architecture, making it easier to develop and maintain web applications.

  4. JSF (JavaServer Faces): JSF is a framework for building user interfaces for web applications, providing a component-based architecture and a set of standard components.

Java Virtual Machine (JVM)

Java programs are executed by the Java Virtual Machine (JVM), a software layer that interprets Java bytecode and converts it to machine code that can be executed by the operating system. The JVM provides a number of features that make Java programming efficient and platform-independent, including:

  1. Memory Management: The JVM automatically manages memory allocation and deallocation, allowing developers to focus on writing code rather than managing memory.

  2. Garbage Collection: The JVM includes a garbage collector that automatically frees up memory used by objects that are no longer needed, preventing memory leaks and other performance issues.

  3. Platform Independence: Because the JVM runs on top of the operating system, Java code can be compiled once and run on any platform that has a JVM installed.

  4. Security: The JVM includes a number of security features, such as a bytecode verifier that ensures that code is safe to execute and a security manager that controls access to system resources.

  5. Debugging: The JVM provides a number of debugging tools, including stack traces, memory dumps, and performance monitoring tools.

Common Mistakes to Avoid in Java Programming

While Java programming can be a powerful tool for developers, it’s also easy to make mistakes that can cause bugs or make your code difficult to maintain. Here are some common mistakes to avoid in Java programming:

  1. Not using object-oriented principles: Java is an object-oriented language, and not using object-oriented principles can make your code less efficient and harder to maintain.

  2. Ignoring memory management: Java handles memory management automatically, but developers still need to be mindful of their code’s memory usage to avoid performance issues.

  3. Not handling exceptions properly: Failing to handle exceptions properly can cause your code to crash or behave unpredictably.

  4. Not following coding standards: Ignoring coding standards like naming conventions or coding styles can make your code harder to read and maintain.

  5. Writing inefficient code: Writing inefficient code can cause performance issues and slow down your application.

  6. Not testing your code properly: Failing to test your code thoroughly can cause bugs and make it harder to maintain.


Java is a powerful and versatile programming language that is widely used in various applications. Its object-oriented approach, platform independence, and robust exception handling make it an excellent choice for developers looking to create reliable and scalable software applications. If you’re interested in learning Java programming, there are plenty of online resources available to help you get started.

Java programming is a powerful language that offers many features, frameworks, and libraries for developers to create sophisticated and reliable applications. By following best practices like using clear naming conventions, writing concise code, and testing your code thoroughly, you can ensure that your Java code is maintainable, efficient, and reliable. Whether you’re a beginner or an experienced developer, there’s always something new to learn in the world of Java programming.

1 thought on “Java Programming Under A Bluesky: learn from basics now part-1”

Leave a Comment

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights