Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Java
1. Java

Java is a strongly-typed general purpose programming language. Oracle owns Java.
Java is at the heart of our digital lifestyle. It's the platform for launching careers, exploring human-to-digital interfaces, architecting the world's best applications, and unlocking innovation everywhere—from garages to global organizations. From the web site at
https://www.java.com
2. CentOS installation
The Java runtime should already be installed, but the Java
SDK (
Software Development Kit) that includes the compile and tools for program development may not be installed.
3. Verify the runtime
Check the version of Java runtime installed with the following command.
The following Linux command(s) verify the installed Java runtime version.
java -version
On
2019-08-04 the output was as follows.
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
4. Verify the compiler
The following Linux command(s) verify the installed Java SDK.
javac -version
On
2019-08-04 the output was as follows.
javac 1.8.0_222
If the Java SDK is not present, then it needs to be installed.
5. Install the SDK
The following Linux command(s) install Java SDK.
sudo yum -y install java-devel
6. Hello world in Java
The file type of a
Java program file is
java.
The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.java
Create the following program text in the editor that will output the text "Hello world"
public class hello {
public hello() {
System.out.print("Hello world\n");
}
public static void main(String [] args) {
new hello();
}
}
To exit with save, remember to press
Ctrl-X, then "
y" (for yes) and
Enter to exit.
The following Linux command(s) run the program.
javac -cp ~ hello.java
java -cp ~ hello
The output should be as follows.
Hello world
7. End of page
8. Acronyms and/or initialisms for this page
1 acronyms omitted (login required)