Search This Blog

Wednesday, March 28, 2012

Importing Java source code to eclipse from netbeans

A friend wrote a Java program for analysis with a GUI, etc and I needed to import the source, edit it, compile, etc.

These are the steps to get it up and running in Eclipse.  I've been using eclipse lately instead of netbeans, no comment on which is better, but Eclipse is up and running on my machine and seems lighter on my laptop.

  • ·         Download and unzip eclipse, windows 32 or 64 bit whatever your machine can run
o   You may need to download java re from oracle if you don’t already have it on your machine  You may have to tell eclipse where the JRE is also.  File->Properties-> Java Build Path-> Libraries, add library. Often C:\Program Files\Java\

  • ·         Unzip the file and click on eclipse icon
  • ·         Set your workspace to a directory where you want to keep your projects
  • ·         Go to workbench in the opening GUI
  • ·         File->New->Java Project
  • ·         Name the project and set JRE to JavaSE-1.6 or whatever you have installed
  • ·         You will see the project appear in the browser with a src and the JRE system library as sub folders
  • ·         Right click on the project src folder and create a new package, call it the same as at the top of the Java files, “backplane2”
  • ·         Select and drag all the .java files onto the src/package name you just created in the Package Explorer” tree on the left.   You will get a [+] and a dialog will pop up asking if you want to copy the files.  Click OK
  • ·         You shouldn’t see any red marks on the java files if all the files and package names are clean
  • ·         Create a run Configuration
o   Run->Run Configurations
o   Java Application
o   New (icon in upper left)
o   Browse and select the project name and Main Class for your project you created
o   Click “Include system libraries when searching”

  •             If you have a GUI  Form file in your source, you can right click on it, select Edit With->Windows Builder to enable the editor to let you edit the file with the graphical GUI builder instead of just the text editor.

  •       Resolve any errors that appear in the files by right clicking, etc.  You may find you are missing a file, need to import a library, etc.  Right click will tell you what's wrong.

1 comment:

  1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.