How to simply create an Eclipse project and add some existing java source files ?

G

Gunter Hansen

I have developed some simple java classes (files) with some GUI elements. Nothing special.
Up to this point I developed these classes by using the command line JDK v1.4.2

Now I want to use Eclipse as development IDE for the further development.

I installed successfully Eclipse and started it but then the questions start:

I clicked menu File->New->Project and the wizard let me choose
e.g. between "Java project", "Java"->"Java Project" and "Simple".
Hey, what's the difference?

Ok, I selected "Java Project" and clicked next, next, Finish.

Now I wanted to add the previously created java sources outside of Eclipse.

How do I do this?

If I right click in the PackageExplorer on myProject and select "import" I cannot see
a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
or similar.
If I move my old *.java files to the workspace folders they are not automatically included

So again: How do I add external source files otherwise?

Gunter
 
O

Oliver Wong

Gunter Hansen said:
I have developed some simple java classes (files) with some GUI elements.
Nothing special.
Up to this point I developed these classes by using the command line JDK
v1.4.2

Now I want to use Eclipse as development IDE for the further development.

I installed successfully Eclipse and started it but then the questions
start:

I clicked menu File->New->Project and the wizard let me choose
e.g. between "Java project", "Java"->"Java Project" and "Simple".
Hey, what's the difference?

Ok, I selected "Java Project" and clicked next, next, Finish.

Now I wanted to add the previously created java sources outside of
Eclipse.

How do I do this?

If I right click in the PackageExplorer on myProject and select "import" I
cannot see
a "java source" entry. Alternatively I did not found a menu entry "add
external java sources"
or similar.
If I move my old *.java files to the workspace folders they are not
automatically included

So again: How do I add external source files otherwise?

After you've added your old *.java files to the workspace folder,
refresh the project (there's a menu item to do this, or click on the
project, then press F5). Your files should not be visible in the project. If
not, post again, I'll try to give another solution.

- Oliver
 
D

ducnbyu

After you moved the *.java files to the workspace did you do a refresh
(right click on the package explorer to see the refresh option)? I was
able to add java to a project this way.
 
C

Chris Smith

Gunter Hansen said:
I clicked menu File->New->Project and the wizard let me choose
e.g. between "Java project", "Java"->"Java Project" and "Simple".
Hey, what's the difference?

Ok, I selected "Java Project" and clicked next, next, Finish.

Now I wanted to add the previously created java sources outside of Eclipse.

How do I do this?

In order for Eclipse to see a source file, it needs to reside in a
source folder. If you created a project using a recent version of
Eclipse and didn't change the defaults, then there is probably a
directory in your project called "src". Put your source code there.
Also, as Oliver said, right-click the project and choose "Refresh" after
it's there.

If you don't want to put your source code in the project, you can
"link" the source code to the project instead. In that case, you should
do the following:

1. Right-click the project, and choose Properties from the context menu.
2. Select "Java Build Path" from the left-hand side.
3. Click the "Source" tab along the top.
4. Click the "Link Source..." button.
5. Fill out the dialog box, and click the OK buttons.

That should create for you a sort of "virtual" source folder that really
points elsewhere on your disk drive. For example, I've seen people do
things this way in order to keep source code where Tomcat can find it in
the webapps directory, but still develop it from Eclipse. I think
that's a bad idea, and in fact I can't think of a good reason to use
"Link Source", but it's there anyway if you want it.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

Carl

Gunter said:
I have developed some simple java classes (files) with some GUI elements. Nothing special.
Up to this point I developed these classes by using the command line JDK v1.4.2

Now I want to use Eclipse as development IDE for the further development.

I installed successfully Eclipse and started it but then the questions start:

I clicked menu File->New->Project and the wizard let me choose
e.g. between "Java project", "Java"->"Java Project" and "Simple".
Hey, what's the difference?

Ok, I selected "Java Project" and clicked next, next, Finish.

Now I wanted to add the previously created java sources outside of Eclipse.

How do I do this?

If I right click in the PackageExplorer on myProject and select "import" I cannot see
a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
or similar.
If I move my old *.java files to the workspace folders they are not automatically included

So again: How do I add external source files otherwise?

Gunter

Gunter,

In the package explorer, right click your new project and select
import, then select the "File system" option. Here you should be
presented with a dialog that allows you to browse for a directory.
Select the base directory that contains you source files, and then
check the files/directories you would like to import.

Hope that helps,
Carl.
 
C

Carl

Gunter said:
I have developed some simple java classes (files) with some GUI elements. Nothing special.
Up to this point I developed these classes by using the command line JDK v1.4.2

Now I want to use Eclipse as development IDE for the further development.

I installed successfully Eclipse and started it but then the questions start:

I clicked menu File->New->Project and the wizard let me choose
e.g. between "Java project", "Java"->"Java Project" and "Simple".
Hey, what's the difference?

Ok, I selected "Java Project" and clicked next, next, Finish.

Now I wanted to add the previously created java sources outside of Eclipse.

How do I do this?

If I right click in the PackageExplorer on myProject and select "import" I cannot see
a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
or similar.
If I move my old *.java files to the workspace folders they are not automatically included

So again: How do I add external source files otherwise?

Gunter

Gunter,

From the package explorer, right click your project and select import,
then "File System", you should now be presented with a dialog where you
can browse the file system. Here, open the base directory that contains
your source files, then check the files/directories you would like to
import. Review the options in the bottom checkbox group, and click
finish.

Hope that helps,
Carl.
 
D

Dave Mandelin

Hi,

Getting started in Eclipse is notoriously tricky. You did it right so
far, though. All you have to do to finish is right click your project
and click 'Refresh'. This will refresh the project against the actual
contents of the directory.

'Simple', by the way, is a project that is just a directory. I.e., it
won't be set up to build Java programs or anything like that.
 
C

Carl

Gunter said:
I have developed some simple java classes (files) with some GUI elements. Nothing special.
Up to this point I developed these classes by using the command line JDK v1.4.2

Now I want to use Eclipse as development IDE for the further development.

I installed successfully Eclipse and started it but then the questions start:

I clicked menu File->New->Project and the wizard let me choose
e.g. between "Java project", "Java"->"Java Project" and "Simple".
Hey, what's the difference?

Ok, I selected "Java Project" and clicked next, next, Finish.

Now I wanted to add the previously created java sources outside of Eclipse.

How do I do this?

If I right click in the PackageExplorer on myProject and select "import" I cannot see
a "java source" entry. Alternatively I did not found a menu entry "add external java sources"
or similar.
If I move my old *.java files to the workspace folders they are not automatically included

So again: How do I add external source files otherwise?

Gunter

Gunter,

In the package explorer, right click your new project and select
import, then select the "File system" option. Here you should be
presented with a dialog that allows you to browse for a directory.
Select the base directory that contains you source files, and then
check the files/directories you would like to import.

Hope that helps,
Carl.
 
P

Paul Hamaker

If you choose 'import', then 'File system', you'll be able to select a
folder and files to be copied to your project.
Linking an existing source folder is a bit akward, goes like this :
Right-click the project name,
New, Folder
Name it, Advanced
Check link to folder in file system
Browse to it
Finish
Wait, it's not over yet...
Right-click project name,
New, Source folder
Same name as the folder you just made,
Finish.
I don't know if the last step is really necessary, but I do it anyway
and it works for me.
You might also take a look at my short guide to Eclipse :
http://javalessons.com/eclipse/java-eclipse-1.html
 
P

Paul Hamaker

Luckily, kicking myself is not that easy.
Right-click the project name,
Build path,
Link additional source to project !!!!!!!!!!!!!!!

Simple is right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top