I am not a Java programmer nor do I aspire to become one. However, sometimes I am compelled to help short people with Minecraft problems and other annoyances.
This is a very good article outlining the main ideas of Java as a concept.
What Kind Of Java Do I Have?
This command will tell you a lot.
java -XshowSettings:properties -version
I still found it tricky to know if I had Java 7 or 8 or whatever.
Installing on Ubuntu
And maybe Debian?
Let’s say you need "Java 8" because someone told you that’s what you need. This worked for me.
sudo apt install openjdk-8-jdk
Apparently just doing apt install java
gets you Java 10 these days
(2018-10-02).
Installing On CentOS/Red Hat
This web page seems to cover the topic well. It seems to have worked for me installing Oracle Java 8 JRE on CentOS 6 in 2016.
Hello World
When I tried Java in the 1990s it was horrific and getting even the simplest thing to happen, especially on Linux, was an ordeal. But today it seems pretty well behaved.
:-> [host][/tmp]$ cat HW.java
class HW {
public static void main(String[] args)
{ System.out.println("Hello, world!"); }
}
:-> [host][/tmp]$ javac HW.java
:-> [host][/tmp]$ time java HW
Hello, world!
real 0m0.298s
Jar
Sometimes you want to make jar files like you mean it. The Debian
package fastjar
gets you /usr/bin/jar
. Remember, jar files are
just zip files with a different name and some conventions about what
files are contained therein.
Very often someone just wants you to "run" a Java program. You get a jar file and then what? Something like this.
java -jar minecraft.jar