ModderDojo Java Modding 3: Getting Started With Eclipse

Previous post: ModderDojo Java Modding 2: Setting Up Your Development Environment
Next post: ModderDojo Java Modding 4: Creating Our First Mod – Getting Started

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

newproj

Enter a project name, e.g. Test:

newproj2

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:

newclass

You now have a starting piece of code:

test1java

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:
System.out.println(“Hi there”);

testjava2

Press the Save icon and then the green Run icon to run your first program:

hellodlg

Previous post: ModderDojo Java Modding 2: Setting Up Your Development Environment
Next post: ModderDojo Java Modding 4: Creating Our First Mod – Getting Started

3 thoughts on “ModderDojo Java Modding 3: Getting Started With Eclipse

  1. Pingback: ModderDojo Java Modding 1: Beginning Java Mods with Forge | CoderDojo Athenry

  2. Pingback: ModderDojo Java Modding 2: Setting Up Your Development Environment | CoderDojo Athenry

  3. Pingback: ModderDojo Java Modding 4: Creating Our First Mod – Getting Started | CoderDojo Athenry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s