Monday, August 30, 2010

How to set up Eclipse IDE for Ubuntu Linux

Being an avid user of Ubuntu Linux, and various flavors of Linux as a whole, I have to give at least a basic how to on getting the Eclipse Java IDE to install and run for other users of Ubuntu.

First and foremost anyone looking to use Eclipse to make a Java program is going to want to ensure that you have the Java SDK installed. As such, you're going to want to follow this tutorial:

Now, I'm sure you guys are thinking "Well, Jimbo, why didn't you just tell us how to do all that?!" and to be honest theres no reason I couldn't. I guess a little part of me just wanted to make sure I didn't mess that up for you folks. Following that guide will ensure you get the java SDK installed properly and hopefully working.

Here's where I come in handy. It is late here and I didn't plan to do this, but it came to me as an idea when i realized I wasn't sure how to set up the Java project settings in Eclipse when i tried to use Eclipse to program while i was reading the book.

Theres an easy method and a more time consuming method out there, first the easy method.

Open up a terminal (Applications > Accessories > Terminal )
Once in the terminal type the following:

sudo apt-get install eclipse
Hopefully this works for you, it didn't for me ;).

With all the troubles I went through I ended up at a site I've visited quite frequently known as Ubuntu Community Help . This page describes how to do a number of things but the one i had to follow was the User Installation section. 

Once you get it installed and want to proceed with creating a Java project in there to get some programming on then go ahead and keep reading. Open up Eclipse first, there will be a dialog box about a default workspace, go ahead and leave it or change it since it doesn't much matter. the workspace controls where all the files and projects get stored on your hard drive.

While in Eclipse go ahead and click "File > New > Java Project" . Once you press Java Project you'll see a window like this:

Theres a few options here that matter, quite a bit actually. The first thing you'll notice is Project Name: and thats the big one, name it whatever you would like, it's going to refer only to the project and not the class file. Below that you'll see the content section radio buttons, just select the top one "Create new project in workspace". Then you'll see the JRE section below that, this is the important one, go ahead and select the top one and in the drop down button select yourself "JavaSE-1.6" if you don't have it in the list let me know, I'll see if I can't help. Theres two more sections left, Project layout and Working sets. On project layout go ahead and select the second option of creating seperate folders. Lastly the Working sets leave that blank for now. Press Finish.

Once you press finish hopefully you'll be brought back to the main Eclipse window with a little bit of new stuff on the left hand side. Under the Package Explorer \ Hierarchy section you should now be seeing your project name.Double click on it and you'll see something along the lines of this:

With "src" being selected, go ahead and right click it or go to File. In the menu select "New > Class". once you've done that you'll see a new popup similar to this:

Leave everything pretty much default. For a simple rundown, the Source folder should be your project name followed by "/src" so mine for example is "Enter_Name_Here/src". Package can be left blank, which is default. I'm not sure what Enclosing type is, so google that if possible. Name will be the only thing to change here. The name of this class will be well, the name of your class you'll be programming. So if this is your first program or whatever enter "HelloJava" in that box. Make sure the Modifiers radio button is selected to public and the rest should be left to default. Go ahead and press Finish now.

You'll be taken back to your main window of Eclipse again. If you did everything right you should be presented with a screen with a very similar look to this:

Hopefully, from there you'll know where to go, the center box is your main code section and where you'll be doing most of the work. 

I hope this helped someone, since for some reason my brain wasn't working when I tried to do this very thing. Obviously I figured it out and am now in business making Java things.

Good luck!

No comments:

Post a Comment