Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Eclipse (How to add file to Project?)

Reply
Thread Tools

Eclipse (How to add file to Project?)

 
 
Duke McPherson
Guest
Posts: n/a
 
      05-08-2006
Using Eclipse, how do you get an existing java file to become part of
the project, so that other java files can use it (equivalent to
#include in C)? This seems like it should be easier than it is...

Thanks!

 
Reply With Quote
 
 
 
 
Larry
Guest
Posts: n/a
 
      05-08-2006
Duke McPherson wrote:
> Using Eclipse, how do you get an existing java file to become part of
> the project, so that other java files can use it (equivalent to
> #include in C)? This seems like it should be easier than it is...
>
> Thanks!


If it is a JAR file you want to add, goto Projects -> Properties ->
Java Build Path and select "Add External JARs".

 
Reply With Quote
 
IchBin
Guest
Posts: n/a
 
      05-08-2006
Duke McPherson wrote:
> Using Eclipse, how do you get an existing java file to become part of
> the project, so that other java files can use it (equivalent to
> #include in C)? This seems like it should be easier than it is...
>
> Thanks!
>

You did not specify if this is a java source and or class file. There
are at least three two ways to do what you want to do.

First
- put your target file into a jar file.
- Right click on your Eclipse project and select "Properties"
- Select "Java Build Path"
- Select "Add External Jar" and add that jar file you created
- Your project now has access.

Second
- Select main menu Windows\Preferences\Java\Build Path\Classpath Variables
- Add a path to your external code
- then you can add to your projects

Third
- Create a project in Eclipse for you external code.
- House it here
- Any other project that wants to reference this code the do the
following:
- Right click on your Eclipse project sand select "Properties"
- Select Project references
- Select the project you just created do that


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      05-08-2006

"Duke McPherson" <> wrote in message
news: oups.com...
> Using Eclipse, how do you get an existing java file to become part of
> the project, so that other java files can use it (equivalent to
> #include in C)? This seems like it should be easier than it is...


Two others have given you some answers. Note that "#INCLUDE" in C is a
preprocessor directive, and is part of the preprocessor language. It's
independent of any IDE. That is, the #INCLUDE directive should function the
same way whether you're using Notepad, Emacs, vi, or anything else.

The way you've phrased your question makes it sound like you're asking
about how to do something specifically within Eclipse, which is why the
others have given the answers they did. If they answered the "wrong"
question, you should probably clarify this inconsistency above.

- Oliver

 
Reply With Quote
 
Duke McPherson
Guest
Posts: n/a
 
      05-08-2006

IchBin wrote:
> You did not specify if this is a java source and or class file. There
> are at least three two ways to do what you want to do.


Java source file. I already have my Eclipse project. I just want
other .java files to be part of the project.

Thanks for the help!

 
Reply With Quote
 
James McGill
Guest
Posts: n/a
 
      05-08-2006
On Mon, 2006-05-08 at 16:28 -0700, Duke McPherson wrote:

> Java source file. I already have my Eclipse project. I just want
> other .java files to be part of the project.



Put them in the correct dir under your project, and hit File->refresh in
Eclipse.

 
Reply With Quote
 
IchBin
Guest
Posts: n/a
 
      05-08-2006
Duke McPherson wrote:
> IchBin wrote:
>> You did not specify if this is a java source and or class file. There
>> are at least three two ways to do what you want to do.

>
> Java source file. I already have my Eclipse project. I just want
> other .java files to be part of the project.
>
> Thanks for the help!
>

OK.. Just select you project or package you want load then into:

- right click and the select "Import"
- Select file system
- Browse to the when the programs are then select the ones you want
- Then "finish"


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
Reply With Quote
 
Duke McPherson
Guest
Posts: n/a
 
      05-09-2006
Thanks you guys, that worked. ; )

 
Reply With Quote
 
Alex
Guest
Posts: n/a
 
      05-09-2006
Easiest way is drag/drop java file from your windows folder to folder
inside Eclipse (not Windows! Just in the Eclipse!).

 
Reply With Quote
 
JimDanz JimDanz is offline
Junior Member
Join Date: Aug 2009
Posts: 1
 
      08-10-2009
Quote:
Originally Posted by James McGill
On Mon, 2006-05-08 at 16:28 -0700, Duke McPherson wrote:

> Java source file. I already have my Eclipse project. I just want
> other .java files to be part of the project.



Put them in the correct dir under your project, and hit File->refresh in
Eclipse.
Thank you James, this is exactly what I needed.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validate WSDL in eclipse using Eclipse Web tools project Veerle Java 0 03-13-2009 01:09 PM
Convert NetBeans Project to Eclipse Project (Java Applicaiton) gc Java 0 02-13-2008 04:37 AM
How to create .ear file in Eclipse 3.1.0 (Lomboz 1.0) from Enterprise Application Project? John F. Java 0 10-14-2005 10:20 PM
how to create an applet java in eclipse from a project whichs depends from a jar file? welsungo Java 0 03-05-2005 11:12 AM
Deploying eclipse plugin cleared everything in eclipse - project references in package explorer etc. javaguy44 Java 1 08-18-2004 03:24 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57