JavaRush /Java Blog /Random EN /Where to start learning Java
Alex
Level 37

Where to start learning Java

Published in the Random EN group

Java language

Java is not just a programming language, but an entire software platform with extensive capabilities. The main components of this platform are: Where to start learning Java - 1
  • Basic tools for writing and running Java programs.
  • Libraries and classes are the core of the language. They provide core Java programming functionality: exception handling, multithreading, collections, logging, reflection, security, networking, XML, serialization, regular expressions.
  • Tools for deploying and automatically launching applications.
  • Tools for creating frontend (GUI, user interface). These are classes of the JavaFX, Swing and Java2D libraries.
  • Libraries for working with databases remotely over the network, such as JDBC, JNDI, RMI and Java RMI-IIOP.
If you want to learn more about Java classes and tools, read the Oracle documentation - it's all there. The first version of Java JDK 1.0 included “only” a few hundred classes. But now their number has increased to several thousand. Over the life of the language, the authors have made a huge number of changes that increase its security, functionality and portability. Thanks to the constant improvement and support of the language by its developers, Java has always kept pace with the development of IT technologies. So now we have before us a modern language, the main characteristics of which are:
  • Low barrier to entry.
    Java is easier to learn than most languages ​​with C-like syntax.

  • Object orientation.
    Java programs are built around objects and their interactions, which allows you to take full advantage of OOP.

  • Portability.
    Through the use of an interpreter, the Java virtual machine, programs are portable to various platforms and devices.

  • Platform independence
    A program written in Java for one platform is compiled into intermediate bytecode that can run on other platforms thanks to interpretation by the JVM for each platform.

  • Advanced multi-threading.
    Java features allow you to control the execution of multiple threads, allowing you to create multi-threaded applications.

  • Safety.
    Thanks to the JVM's built-in bytecode verification, Java's lack of manual memory management, stack overflow detection, and the presence of various APIs that allow you to control security, you can create truly secure applications in this language.

  • Fault tolerance.
    The exception mechanism, both during compilation and during direct execution, increases the fault tolerance of programs and reduces the number of errors.

  • Interpretability.
    The Java interpreter can execute Java bytecodes on any machine that has a JVM and JRE.

  • Distribution.
    Java has tools for creating distributed applications.

  • Performance.
    The use of a JIT (Just-in-time) compiler ensures high-speed application operation, comparable in speed to the C and C++ languages.

How to start programming in Java?

To start learning Java from scratch , it is advisable to understand the basic concepts: what the Java language includes, what a Java program is and how it is executed. Then move on to the syntax of the language, its basics, and study of libraries. After reading a couple of articles about the Java language, you can take on its basics.

The sequence of steps is clearly demonstrated by this flowchart:
Where to start learning Java - 2

What do you need to program in Java?

First, you need to install software for developing and running programs - JDK (Java Development Kit). After that, configure the JDK on your computer, download and install one of the IDEs (Integrated Development Environment) - this is an environment for software development. The most popular IDE is IntelliJ IDEA. Alternatives include Eclipse, NetBeans, JCreator, and even regular notepad.

Installing Java on your computer

As we have already found out, when we learn Java from scratch, the first step is to install the JDK . To do this you will need to do a few simple operations:
  1. Go to the Oracle website .
  2. Select and download the installation file depending on your operating system.
  3. Complete the installation following the instructions of the installer.
  4. Set the environment variable if you are using Windows.
Here, for example, is a description of the JDK installation and environment variables for the Windows operating system.

Basic definitions

If you just started learning Java, you will certainly come across the following terms: JVM (Java Virtual Machine) - Java virtual machine. It is a platform-specific software module that serves to interpret source bytecode into machine code and execute it. JRE (Java Runtime Environment) - Java runtime environment. Includes a platform-specific JVM implementation and a set of libraries needed to run Java programs. JDK (Java Development Kit) is a set of developer tools necessary for writing programs in Java. Includes a compiler, JRE, a set of standard Java libraries, documentation, and various utilities. Source code is a text file in Java with the .java extension. Bytecode is machine-independent low-level code that is a set of instructions for the JVM. Machine code is a set of machine instructions in binary format that are directly executed by the processor. Compilation is the conversion of source code into bytecode. Interpretation - converting bytecode into machine code. Platform is the hardware and software environment in which programs and applications are executed. The most popular platforms are Microsoft Windows, Linux, Solaris OS and Mac OS. This diagram will help you better understand the concepts of JVM, JRE and JDK:
Where to start learning Java - 3

Program life cycle

The life cycle of a Java program begins with writing the source code in text format. Usually, special development environments are used for this - Integrated Development Environment (IDE) , but simple programs can also be typed in a text editor, even Notepad, which comes with any edition of Windows OS. The source code must be saved to a file with a .java extension. Example program HelloWorld.java:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("This is my first program");
    }
}
Before executing this source code, it must be compiled into bytecode using a compiler. The compiler is a utility that is part of the JDK. As a result of its work, we will receive a file with the extension .class. It contains bytecode - instructions for the JVM, the format of which resembles assembly language. Our HelloWorld.java program will be compiled into a HelloWorld.class file. The Java platform does not provide tools for editing bytecode, but you can still view it. To see what the bytecode of a Java program is, you can use the javap disassembler utility, which is included in the JDK. HelloWorld. class will contain bytecode like this:

Compiled from "HelloWorld.java"
public class HelloWorld {
  public HelloWorld();
    Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return

  public static void main(java.lang.String[]);
    Code:
0: getstatic #2//Fieldjava/lang/System.out:Ljava/io/PrintStream;
3: ldc       #3// String This is my first program
5:invokevirtual#4//Methodjava/io/PrintStream.println:(Ljava/lang/String;)V
8: return
}
Our program is now stored in compiled form in the HelloWorld.class file. To run it on any platform, you need to have the JRE installed. The portability of Java programs to any platform is ensured through the use of the JVM. Program execution is the execution of bytecode by the Java virtual machine. The programs are executed by the java utility, which requires you to specify the name of the compiled file. Execution occurs in the following sequence:
  1. The JVM runs in the computer's RAM. Essentially, this is a program that is used to execute Java programs that we have written.
  2. Using the initial class loader, the JVM loads and initializes our class in the computer's memory. In our example, this is the class HelloWorld.
  3. Next, in our class, the JVM looks for the public static void main(String[]).
  4. The method code is executed main. If this is necessary for program execution, other classes are loaded and initialized.
  5. After the code is executed, garbage collection is performed - memory is cleared and the JVM program is closed.
When performing all these actions, the JVM interprets (converts) the bytecode into a machine instruction for the processor, taking into account the operating system on which it is executed. The life cycle of a Java program can be schematically represented as follows:
Where to start learning Java - 4

Selecting and installing a development environment

To program in Java quickly and efficiently, you need a development environment—an application for writing Java programs. The most popular IDEs among Java developers are:
  • IntelliJ IDEA
  • Eclipse
  • NetBeans
According to a survey of the popularity of Java development tools prepared by RebelLabs, in 2017 IntelliJ IDEA became the leader , Eclipse took second place, and NetBeans was in third place with a significant lag behind the pair of leaders. The share of other IDEs is small and does not exceed 3% of the total volume. A good comparison review of these IDEs can be found here . For beginners, it is enough to install IntelliJ IDEA Community Edition. Firstly, you will get all the advantages of a modern IDE, such as: hints, code checking, the ability to debug code, convenient integration with databases, servers and support for many development tools and technologies. Secondly, you will take the first step in mastering the professional development tool used by most developers. Instructions for installing IntelliJ IDEA are provided at the beginning of the third level of the JavaRush online training course .

How long does it take to learn Java?

Learning the basics of Java and becoming proficient in programming will likely take you anywhere from 6 to 12 months, depending on the intensity of your training. To make this process systematic, create a study plan, collect the necessary resources, and set aside several hours a day for studying. Don't forget that the key to learning to program is practice.

Conclusion

When we learn Java on our own, it turns out to be easier in practice than in theory. For this, knowledge at the level of a personal computer user is quite sufficient. To effectively start learning Java, follow a few simple steps:
  1. Install Java on your computer
  2. Learn the basic concepts
  3. Set up your development environment
  4. Write and run your first program.
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION