Environment for Java programming
Simply said, I love Java! It is cross-platform, fast, powerful and widely used. Java is not easy programming language to learn but it will allow us to do some grate stuff in the future.
Simply said, I love Java! It is a cross-platform, fast, powerful and widely used. Java is not an easy programming language to learn but it will allow us to do some great stuff in the future. To get some basic knowledge of Java, I recommend you to watch Derek Banas video since it contains a lot of useful information. Beside pure Java, we are also going to use Spring Framework with Spring Boot. Here I recommend you to watch Java Brains tutorials since this was the starting point for me and it worked. In this text I will only show you my environment setup and workflow, but have in mind that if you already have a workflow that is working for you, stick to it or try this one if you wish.
Java 8 - Linux
- Go to Oracle website and follow the instructions.
- Now we will add installed JRE as JAVA_HOME.
- Go to profile
vim /etc/profile, add next lines and save file.
# Chnage _USER_ to your linux user
export JAVA_HOME="/home/_USER_/"
export PATH=$JAVA_HOME/bin:$PATH- Reboot your system. After this, if you execute the command
java -versionyou will see something like this:
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)Java 8 - Windows
- Go to Oracle website and download JDK for Windows. Have in mind that you need to check Accept License Agreement.
- After download is done, run the executable and just follow the instructions.
- Open PowerShell and type
java -version. The system should report something like this:
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)Eclipse IDE for Java
- Go to Eclipse website and download Eclipse IDE for Java Developers.
- Extract ZIP file somewhere in your filesystem.
- Run Eclipse and select a workspace. You can use the default or create your own.
- After this Eclipse will open selected workspace.

Java - Hello World
- In Eclipse, create new Java project and call it hello-world.

- In src directory of the project create package com.test.threads and in it class Main.
- Create main public method and print Hello World to the console. By running the program (press F11 on keyboard) we can see that the Hello World! message appears in console.

- Now lets create an executable of our small project. Right click on the project and choose Export.

- Go to Java and select Runnable JAR.
- Select Launch Configuration (project) and select directory where the JAR will be exported, then click Finish.
- Since I selected Desktop as the export directory, I will open PowerShell, navigate to desktop and here I can see may JAR file by running
dircommand. - Now start JAR by running the command
java -jar hello-world.jarand you will be able to see Hello World! message printed in console.

Processing
Processing is a library for Java that will give us tools for simulation and data visualization. Of course, Processing is much more than this, it will give us a canvas for 2D or 3D animations with OpenGL acceleration. It can be used without the Eclipse and you can find awesome tutorials about it on The Coding Train Youtube channel. Now we will see how to add Processing libraries to an Eclipse project.
- In Eclipse, create a new Java project called processing-starter.
- In the root of the project, create folder called libs.
- Go to Processing website and download it.
- Open ZIP file, go to core/library and copy all JARs to libs folder in the Eclipse.
- Add all libraries to Build Path and you should have something like in the image below.

- Now create class Main inside of the com.test.threads package.
- Set Main class to extend PApplet class.
- Create main method and into it set PApplet main class like shown in the code below.
import processing.core.PApplet;
public class Main extends PApplet {
public static void main(String[] args) {
PApplet.main("com.test.threads.Main");
}
}- Now we need to write few default methods of PApplet used for creating GUI window and drawing into it.
import processing.core.PApplet;
public class Main extends PApplet {
// Define main class for PApplet
public static void main(String[] args) {
PApplet.main("com.test.threads.Main");
}
// Set window size and enable 2D acceleration
public void settings() {
size(600, 400, P2D);
}
// Setup the environment
public void setup() {
settings();
frameRate(30);
}
// Loop method that is drawing pixels in the window
public void draw() {
background(140, 70, 260);
}
}- If you run the program, GUI window should pop up with background color that we have set with background function.
In the future I will do some projects in which we will use Processing to simulate movement of mathematical model since Processing animations are more fun and prettier then simulations from Wolfram Mathematica or Matlab. Of course, those two programs are really powerful and we are going to use them too. I created simple Snake Game using Processing to give you something interesting and motivate you to learn Java and Processing since it is a lot of fun.
