Master Mobile Automation on Upwork with Java
Table of Contents
- Introduction to Java Programming Language
- Java Development Kit (JDK)
- Java Runtime Environment (JRE)
- Java Virtual Machine (JVM)
- Platform Independence of Java
- Object-Oriented Programming Concepts in Java
- Installing Java on Windows
- Setting up Environment Variables for Java
- Installing Java on Linux
- Selecting Java Version to Use
Introduction to Java Programming Language
Java is a popular programming language and computing platform for application development. It was first released by Sun Microsystems in 1995 and later acquired by Oracle Corporation. Java is a platform-independent language, which means it is not specific to any processor or operating system. It is intended to let application developers write once and run anywhere. Java is an object-oriented language, so in Java, everything is an object. Java is designed to be easy to learn and master, especially if You understand the basic concepts of object-oriented programming.
Java Development Kit (JDK)
The Java Development Kit (JDK) is a software development environment used to develop Java applications. This Package includes all the tools that you'll need to develop with Java. If you want to develop and run applications, you are required to set up JDK on your machine. It contains Java Runtime Environment (JRE) as well as development tools like Java debugger, etc.
Java Runtime Environment (JRE)
Java Runtime Environment (JRE) is a software package that bundles the libraries and the Java Virtual Machine (JVM), as well as other components to run applications written in the Java language. The JRE is the runtime portion of Java software, which is all you need to run it in your web browser. It contains JVM and libraries.
Java Virtual Machine (JVM)
Java Virtual Machine (JVM) is the virtual machine that runs a Java program. When you run the Java program, the Java compiler first compiles your Java code to bytecode, and then you get this bytecode by compiling the .java files into .class files. The .class files contain the bytecodes understood by the JVM.
Platform Independence of Java
Java is a language that is platform-independent, so it's not specific to any processor or operating system. That means a compiled Java code can run on all platforms that support Java without the need for re-compilation. For example, you can write and compile a Java program on Unix and run it on Microsoft Windows, Macintosh, or Unix machine without any modifications to that source code.
Object-Oriented Programming Concepts in Java
Since Java is Based on the object model, it can be easily extended. Java is designed to be easy to learn and master, especially if you understand the basic concepts of object-oriented programming. In the following lectures, we will cover object-oriented programming concepts.
Installing Java on Windows
Installing Java on Windows is very easy. We will use the latest version of Java, which is JDK 11. To install Java on Windows, go to your favorite search engine, which is Google, and search for Java JDK 11. In the search results page, choose the first link, and you'll see the Java Standard Edition Development Kit 11 downloads page on the Oracle site. There are a lot of download links on this page, so choose the .exe version that will best suit you. If you don't know your operating system, click the search button on your desktop and write device specifications into the search box, and you'll see your operating system Type in the System Type section.
Setting up Environment Variables for Java
After installing Java on your system, you need to set up the environment variable. To do this, open up the Control Panel and choose the System and Security section, and click on System. Click Advanced system settings on the left-HAND side, and then click the option Environment Variables. On the System Variables, select the Path option, and then click on the Edit button. Add the Java JDK location into your system. Search PC and then open the C drive and choose Program Files, the Java folder, and JDK11, and go to the bin folder. Copy this path from the address bar and return to the Environment Variable page and click New. Paste the path to this location and click OK and close all of these pages. Open up the command prompt to check if you can write Java -version on the command prompt, and if everything goes right, you will see the last version of Java.
Installing Java on Linux
To install Java on Linux, first, we have to add its package repository. Write sudo add-apt-repository ppa:linuxuprising/java as a command on the command line. When you add the repository, you'll see a message, so press enter to Continue, and then update your package list. On the command line, write sudo apt update, and after the package list updates, we will install Java 11. Now write sudo apt install oracle-java11-installer on the command line, and then your system will download the JDK from Oracle and then ask you to accept the license agreement. So of course, you're going to accept the license agreement, and JDK will be installed.
Selecting Java Version to Use
You can have multiple Java installations on one server. You can configure which version is the default for use on the command line by using the update-alternatives command. Write sudo update-alternatives --config java on the command line, and now you can see all the installed versions of Java as a result. Now choose the number associated with the Java version to use it as default, or you can always press enter to leave the Current settings in place. You can do this for the other Java command such as a compiler javac. Write sudo update-alternatives --config java or javac if you want on the command line. This command shows each installation of Java along with its installation path. Copy the path from your installation, then open /etc/environment by using Vim or your favorite text editor. In Vim editor, press the I key to pass the insert mode, and then go to the end of this file and add a line and pass the Java path to this line. Modifying this file will set the Java_home path for all users on your system. You can hit the Escape key and type :wq to save the file and quit the editor. Now reload this file to Apply the changes to your current session. Write source /etc/environment on the command line. Let's check if the Java_home is set properly. First, we'll execute the echo command again, and you will see the Java path. Now write on the command line Java --version, and if everything goes right, you now see the last version of Java.
Highlights
- Java is a popular programming language and computing platform for application development.
- Java is a platform-independent language, which means it is not specific to any processor or operating system.
- Java is an object-oriented language, so in Java, everything is an object.
- Java Development Kit (JDK) is a software development environment used to develop Java applications.
- Java Runtime Environment (JRE) is a software package that bundles the libraries and the Java Virtual Machine (JVM), as well as other components to run applications written in the Java language.
- Java Virtual Machine (JVM) is the virtual machine that runs a Java program.
- Installing Java on Windows and Linux is easy, and you need to set up the environment variable after installation.
- You can have multiple Java installations on one server, and you can configure which version is the default for use on the command line by using the update-alternatives command.
FAQ
Q: What is Java?
A: Java is a popular programming language and computing platform for application development.
Q: Is Java platform-independent?
A: Yes, Java is a platform-independent language, which means it is not specific to any processor or operating system.
Q: What is JDK?
A: JDK is a software development environment used to develop Java applications.
Q: What is JRE?
A: JRE is a software package that bundles the libraries and the Java Virtual Machine (JVM), as well as other components to run applications written in the Java language.
Q: What is JVM?
A: JVM is the virtual machine that runs a Java program.
Q: How to install Java on Windows?
A: To install Java on Windows, go to your favorite search engine, which is Google, and search for Java JDK 11. In the search results page, choose the first link, and you'll see the Java Standard Edition Development Kit 11 downloads page on the Oracle site.
Q: How to install Java on Linux?
A: To install Java on Linux, first, we have to add its package repository. Write sudo add-apt-repository ppa:linuxuprising/java as a command on the command line. When you add the repository, you'll see a message, so press enter to continue, and then update your package list. On the command line, write sudo apt update, and after the package list updates, we will install Java 11. Now write sudo apt install oracle-java11-installer on the command line, and then your system will download the JDK from Oracle and then ask you to accept the license agreement. So of course, you're going to accept the license agreement, and JDK will be installed.
Q: How to set up environment variables for Java?
A: After installing Java on your system, you need to set up the environment variable. To do this, open up the Control Panel and choose the System and Security section, and click on System. Click Advanced system settings on the left-hand side, and then click the option Environment Variables. On the System Variables, select the Path option, and then click on the Edit button. Add the Java JDK location into your system. Search PC and then open the C drive and choose Program Files, the Java folder, and JDK11, and go to the bin folder. Copy this path from the address bar and return to the Environment Variable page and click New. Paste the path to this location and click OK and close all of these pages.