While waiting for Forge to install, let’s try out Eclipse.
If this is your first time running it, you will be prompted to create a workspace: the default location is fine
The first time, a Welcome screen appears, which you can X to close.
Java code belongs in classes, classes are organised in projects, and projects are in a workspace. In Eclipse, you can only have one workspace open at a time, but it can have multiple projects in it and each one can have multiple classes.
Create a new Java project: File – New – Project… then expand Java and select Java Project
Enter a project name, e.g. Test:
If you are asked to switch to the Java Perspective, say yes.
To create a first program class file, select File – New – Class
Give the class a name (no spaces allowed), and tick the box at “public static void main”, as this will create some initial code for you:
You now have a starting piece of code:
Under the “TODO” comment (which you can delete or replace with a comment of your own), write a line of code to put up a message box:
JOptionPane.showMessageDialog(null, “Hello world”);
A red line will appear at JOptionPane, as it is not recognised; hover over it and select the fix “import JOptionPane”, which will add an extra line at the top.
Alternatively (or as well), you could print a line to the system output, which goes the console window – that’s the one at the bottom of the screen in Eclipse:
Press the Save icon and then the green Run icon to run your first program: