This tutorial gives a brief example how to install and setup things to develop Java on Linux Mint system. We will use Geany as the text editor and OpenJDK as the tools. You will also try to create first Java program and run it. I intended this tutorial to help students and beginners who use GNU/Linux with their first days in learning Java. Happy coding!
Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.
The Tools
- Text editor: Geany, a really easy to use IDE for all languages
- Java compiler: javac, included in OpenJDK
- Java runtime: java -jar, included in OpenJDK
- Java platform: OpenJDK, a free software implementation of Java (a replacement of the nonfree Oracle JDK)
- Operating system: Linux Mint, we use here version 19 LTS Cinnamon Edition
Installing Tools
All required tools in Linux Mint can be installed with a single command:
$ sudo apt-get install geany default-jdk
Where:
- geany is the package name of Geany IDE
- default-jdk is metapackage to automatically install latest version of OpenJDK among other versions
- The download size needed in Mint 19 Cinnamon is +/-80MB.
Configuring Tools
No configuration needed in Geany. It automatically recognizes that your typed source code is "Java".
Start Programming
Here's the traditional Hello world program. Save this as program.java. Notice the file name must be the same as class name.
program.java:
public class program {
public static void main(String[] args){
System.out.println("Hello world!");
}
}
How the source code looks like in Geany |
Building and Running
Press Compile button, then press Run button. If your source code is OK, it prints out text "Hello world!" in a new terminal.
The result shown in a new Terminal: "Hello world!" |
Some Questions, Maybe?
- Why not Eclipse or Netbeans? To start learning Java, you don't need big IDEs, the small Geany is already enough.
- How to configure build commands? Go to main menu Build > Set Build Commands > see "Compile" section on top, see "Build" section on bottom.
- Why no more examples? See Further References below.
Further References
- All about Geany IDE: https://geany.org
- Learn Java with examples: https://beginnersbook.com/java-tutorial-for-beginners-with-examples is a good one
- Learn Java to create GUI programs: https://zetcode.com/tutorials/javaswingtutorial is also a good one
This article is licensed under CC BY-SA 3.0.