Java is a popular programming language and a computing platform. Fast, reliable and secure. According to Oracle, a Java patent company, Java runs on 3 billion devices worldwide.
Given the number of Java developers, Java implementations, and companies, it can be said that Java will be around for many years to come.
This tutorial covers everything you need to know about the Java programming language. In particular, you will learn about the features of Java programming, its applications, the reasons for learning it, and how to learn it properly. Get acquainted (gain, obtain) with present-day techniques that came from Java Programming.
Why was Java created? Brief history
In 1991, the Green Team led by James Gosling at Sun Microsystems developed a programming language for digital consumer devices. It was called the language of the oak. Why oak? Because there was an oak tree outside Gosling’s office.
The Green Team established interactive language and television. However, it was very advanced for digital cable TV at that time. Later, the language was renamed Green and eventually changed from Java coffee to Java. That’s why its logo is a cup of coffee.
Since C ++ / C were popular languages, James Gessling designed the language with C ++ / C syntax and a “write once, run everywhere” philosophy. Years later, Sun Microsystems released its first public Java implementation in 1995, announcing that the Netscape Navigator Internet browser incorporated Java technology.
In 2010, Sun Microsystems was wholly acquired by Oracle along with Java.
Java version history
June 1, 1991 – The Java language project begins
2- JDK 1.0 – January 1996
3- JDK 1.1 – February, 1997
4- J2SE 1.2 – December 1998
5- J2SE 1.3 – May, 2000
6- J2SE 1.4 – February, 2002
7- J2SE 5.0 – September, 2004
8- Java SE 6 – December 2006
9- Java SE 7 – July 2011
10- Java SE 8 (latest version) – March 18, 2014
11- Java SE 9 – July 2017
Features of the Java programming language
1. Java is a standalone platform
Java was created with the philosophy of “write once, run everywhere” (WORA). The Java code (specific code and libraries) that you write on one platform (operating system) will be executed on other operating systems without change.
To run Java, an abstract machine called Virtual Java Machine (JVM) is used. JVM executes Java bytecode. The CPU then runs the JVM. Since all JVMs work the same way, the same code works on other operating systems, so we can say that Java is independent of the operating system.
2- Object-oriented language
There are different styles of programming. The object-oriented approach is one of the most popular programming styles. In object-oriented programming, by creating objects, a complex problem is divided into small sets that make the code reusable.
Many programming languages, including Java, Python, and C ++, have object-oriented features. If you want to become a programmer, you have to learn object-oriented programming style.
3- Java is fast
Previous versions of Java have been criticized for being slow. However, now everything is completely different. The new JVM is significantly faster and the processor running JVM is also very powerful.
Java is currently one of the fastest programming languages. Well-optimized Java code is about as fast as low-level languages like C ++ / C and much faster than Python, PHP, and so on.
4- Java is secure
The Java platform provides various features for the security of Java applications. Some of the high level features are:
- Provides a secure platform for developing and running Java applications
- Automatic memory management reduces vulnerabilities and memory loss
- Establish secure communication by protecting the integrity and privacy of data transmission
5- Large standard library
One of the reasons Java is so widely used is that it has a large standard library. The Java environment has hundreds of classes and methods in different packages to help software developers. For example,
- java.lang – For advanced features of strings, arrays, etc.
- java.util – For data structures, regular expressions, date and time functions, and so on
- java.io – for I / O file, exception management and so on
Java applications
Powerful Java technology is ubiquitous and supplies three billion devices worldwide. It is very likely that you have used Java at least once in your life. Here are some important Java users:
1- Android applications: Java uses the Android SDK to develop Android applications.
Web applications : Java is used to create web applications through Status, Servlets or JSPs. Some of the most popular web applications written in Java are: Google.com, Facebook.com, eBay.com, Linkedln.com and…. Note that these sites are not all written in Java.
3- Development of various software : Software such as MATLAB, Vuze, OpenOffice, Eclipse and… use Java.
4- Big data processing: You can use the popular Hadoop software framework, which is written in Java, to process large data. To use it, you must have a good understanding of Java programming.
5- Trading systems: You can write trading software that has a small record with Java. In fact, you should use the Oracle Extreme Java trading operating system.
6. Built-in systems: Although C / C ++ programming languages are still popular for working with built-in systems, Java built-in systems technology has provided the right operating system and runtime for billions of built-in devices. These devices include: TV, SIM card and Blu-ray Disc player.
In addition to these programs, Java is also used in the development of scientific games and applications such as natural language processing and..
Terms you should learn before learning Java
Learning a new programming language is challenging. You may hear new terms that are unfamiliar to a beginner. So we decided to explain the specialized terms that you may come across in the world of Java programming.
- Java – A set of technologies, programming languages and computing platforms for creating and running software. Java is often used to refer to the Java programming language because of its simplicity.
- Java programming language – powerful, general, platform-independent and object-oriented.
- Java8 – The latest version of Java. Our Java tutorials include all the important features of Java 8.
- Java EE, Java ME and Java SE – stands for Enterprise Edition, Micro Edition and Standard Edition, respectively. Java EE is used for applications running on servers. Java ME is suitable for devices with limited resources such as built-in devices. Java SE is the basic Java environment used to create standard programs. Use J2SE if you are a beginner.
- JVM – Java Virtual Machine is an abstract machine that enables a computer to run a Java program.
- JRE – Java run time environment which includes JVM, backup library and other components of Java applications. However, it does not include a compiler or software bug fixer.
- JDK -Java Developer Kit includes JRE and tools such as compilers and debuggers for developing Java applications.
Run Java on the operating system
Java installation steps for Mac OS X and MacOS
1. Download the latest version of the Java platform (JDK).
2- Double click on DMG and follow the instructions to install Java.
3- To confirm the Java installation, go to the terminal and click the following command.
javac -version
If installed correctly, the command displays the Java version (such as javac 1.8.0_60)
The next step is to install the Java IDE in order to write and execute Java code. Here we see the installation steps of Intelli IDEA.
1. Download the generic version of the Intelli IDEA.
2. Open the DMG file and follow its instructions. You may want to save the Intelli IDEA to application folders.
3. Open IntelliJ IDEA. Select “Do not import settings” and click ok. Then click the Jetbrains Privacy Policy button and accept Accept.
4- You can now customize your user interface. You can reject all default settings or select your own custom changes. If you are not sure, just click on Skip All and Set Defaults.
5- At the end, you will enter the welcome page and you can create your project.
6. In the next window on the left, select Java and click NEW to select JDK. Select the JDK installation location that we copied during the Java installation and click Next.
7- In this step, you will see the Create project from template option. Ignore it and click Next.
8- On the next page, select a name for the project and click Finish (for example, Hello)
9- You should see your project in the menu on the left. If not, you can see it from the following path:
Views <Tool Windows <Project
10. Now go to hello> new> Java and name the Class. (Eg First)
11. Write and save the desired Java code.
12. To run the program, go to Run> run and click First.
Install Java on Linux
To install and run Java on Linux, you need to install two programs: Java SE Developer Kit and IDE.
1. Open the terminal and type the following commands.
- sudo add-apt-repository ppa: webupd8team / java
- sudo apt update; sudo apt install oracle-java8-installer
2- Agree with license and service by clicking ok and yes.
3- Congratulations! You have successfully installed java8. Make sure the installation is correct by typing the following in the terminal.
Install IntelliJ IDEA for Linux
1. Download the generic version of IntelliJ IDEA.
2- After downloading, in the terminal, change the current directory to the download directory and extract Java using the following command.
sudo tar xf <filename> .tar.gz -C / opt /
3. Then change the current directory to the IntelliJ IDEA folder.
cd / opt / <intellij-folder> / bin
4. Run the following command to start the IDE.
./idea.sh
5. Do not import settings and click ok. Then click the accept button.
6. IntelliJ IDEA lets you customize your interface. Select the one you like and click Next. Create a shortcut on the desktop for easy access to the program. Then click Next to start all other pages.
7. Now you go to the welcome page. Click Create New Project to create a new project.
8. In the next window, select Java from the left pane. See if JDK is selected in the SDK project. If not selected, click New and go to the installation location. / usr / lib / jvm / java-8-oracle
9- Double click on Next.
10. Write the name of the project (for example, HelloWorld) and click Finish. (If you do not see the sidebar on the left, go to View> Windows Tool> Project.)
11. To add a new Java class, click on the src folder on the left and right, then select new and then Java Class. Write the name of the class. Do not use space in the class name.
12. Write and save Java code.
13. Go to Run> Run to run the program. Then click on the project that creates the executable file and run it.
Install Java on Windows 7, 8, 10
To install Java on Windows, we need to install two programs: Java SE Developer Kit and IDE.
1- Download the appropriate kit for your system.
2- After downloading, open the installation file and click Next. Select “This feature will be used on local hard drive”. Then copy the installation location (yellow highlight) to Notpad and click Next.
3- During the installation, you will be asked to install the JRE as well. Click Next. Finally, click the Finish button.
4. Now you need to edit the PATH variable. Go to Control Panel> System and Security> System. Click Advanced System settings on the left to go to System properties.
5. Click on Environment Variables. Then find System variables at the bottom of the path and click Edit in the next window.
6. Select all the text in the Variable Value field and copy it to Notepad. This makes editing and reviewing easier. Check if the text includes C: \ ProgramData \ Oracle \ Java \ javapath. If there is, go to the next step. If not, copy the installation location that you copied earlier to the bottom of the bin. In fact, C: \ Program Files (x86) \ Java \ jdk1.8.0_112 \ bin; Place Notepad at the end of the text. The jdk model may be different. Now copy all the text and paste it in the Value PATH box.
7. Click ok to save the changes.
8- Open the command prompt to check for the correct installation of Java. Type Java-version. If the version is displayed, you have Java installed correctly.
Install IntelliJ IDEA on Windows
1. Download the public version of IntelliJ IDEA.
2- Open and install the installation file. Create a desktop shortcut for the 64-bit version. Click Next.
3. Now open IntelliJ IDEA from the desktop shortcuts.
4. Select “Do not import settings” and click ok. Then click Accept policy Jetbrains.
5. IntelliJ IDEA lets you customize your interface. You can reject all default settings or select your own custom changes. If you are unsure, just click Skip All and Set Defaults.
6. You enter the welcome page. Select Create New Project.
7. In the next window, select Java on the left side of the window. Click New to select JDK. Select the install location where we copied the JDK during the Java installation.
8. IntelliJ IDEA now detects the installed JDK. Click Next.
9- Select the name of the project. (For example, HelloWorld) Click Finish. If you encounter the message directory does not exist, just click ok. (If you do not see the sidebar on the left side, go to View> Tool Windows> Project Follow.
10. To add a new class, right-click on the src folder and select java, then New Class. Write the class name without space.
11. Write and save Java code.
12. Go to Run> Run to run the program. Click on the project. This will create the executable file.