Skip to main content



      Home
Home » Newcomers » Newcomers » Help with importing a class
Help with importing a class [message #249968] Sat, 23 February 2008 10:04 Go to next message
Eclipse UserFriend
Originally posted by: realmenlikemath.gmail.com

I'm trying to write a java program, and I've got this class file that has
a bunch of methods in it I want to use. I tried dragging and dropping it
into the src file of my project. I tried it the bin and the src, but when
I write my main method, it's still not recognizing the methods from the
other class. I'm new to Eclipse, and new to Java, so excuse me if this
question is ridiculous. Any help would be greatly appreciated.

Thanks,
Jon
Re: Help with importing a class [message #249976 is a reply to message #249968] Sat, 23 February 2008 11:20 Go to previous messageGo to next message
Eclipse UserFriend
Jon Beardsley wrote:
> I'm trying to write a java program, and I've got this class file that
> has a bunch of methods in it I want to use. I tried dragging and
> dropping it into the src file of my project. I tried it the bin and the
> src, but when I write my main method, it's still not recognizing the
> methods from the other class. I'm new to Eclipse, and new to Java, so
> excuse me if this question is ridiculous. Any help would be greatly
> appreciated.
> Thanks,
> Jon
>
Hi Jon. Perhaps the easiest way is to create a new .java file in your
project and package and then copy and paste the content of the class you
want to use into the new .java file. Make sure the package declaration
in the final .java file matches your Eclipse package name. (I suspect
that may be the problem.)

If you are new to Eclipse and Java, you might want to look at the
Eclipse and Java for Total Beginners video tutorial at
http://eclipsetutorial.sourceforge.net.

Hope this helps. Mark
Re: Help with importing a class [message #249980 is a reply to message #249968] Sat, 23 February 2008 11:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

Jon Beardsley wrote:
> I'm trying to write a java program, and I've got this class file that
> has a bunch of methods in it I want to use. I tried dragging and
> dropping it into the src file of my project. I tried it the bin and the
> src, but when I write my main method, it's still not recognizing the
> methods from the other class. I'm new to Eclipse, and new to Java, so
> excuse me if this question is ridiculous. Any help would be greatly
> appreciated.
> Thanks,
> Jon
>
You need to define a Class Folder on the Java Build Path->Libraries tab.
Make sure that the folder has the correct package hierarchy for the
class that you are trying to use and put the class file in the folder at
the appropriate level.

The Class Folder is added to the build class path for the project so the
class will now be available.

Note that content assist will only be able to provide method names. You
won't be able to see any JavaDoc unless you attach source to the Class
Folder.
Re: Help with importing a class [message #250046 is a reply to message #249980] Sun, 24 February 2008 16:28 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

David Wegener wrote:
> Jon Beardsley wrote:
>> I'm trying to write a java program, and I've got this class file that
>> has a bunch of methods in it I want to use. I tried dragging and
>> dropping it into the src file of my project. I tried it the bin and
>> the src, but when I write my main method, it's still not recognizing
>> the methods from the other class. I'm new to Eclipse, and new to
>> Java, so excuse me if this question is ridiculous. Any help would be
>> greatly appreciated. Thanks,
>> Jon
>>
> You need to define a Class Folder on the Java Build Path->Libraries tab.
> Make sure that the folder has the correct package hierarchy for the
> class that you are trying to use and put the class file in the folder at
> the appropriate level.
>
> The Class Folder is added to the build class path for the project so the
> class will now be available.
>
> Note that content assist will only be able to provide method names. You
> won't be able to see any JavaDoc unless you attach source to the Class
> Folder.
>

In addition to that good advice, you should invest a couple of hours in
going through the tutorials that come with Eclipse. They will hlep you
understand how ti works and how best to use it.
Open the Help > Contents and then browse the Workbench User Guide and
Java Development User Guide chapters; find the "Getting Started"
sections and there you'll see the tutorials.
One of the tutorials deals specifically with how to organize projects in
Eclipse, which would have helped you get past the problem above.

Hope this helps,
Eric
Previous Topic:Null Display.getCurrent when running JUnit4/Swt/JFace tests?
Next Topic:How can I view the older items in the news group?
Goto Forum:
  


Current Time: Sun May 11 19:28:40 EDT 2025

Powered by FUDForum. Page generated in 0.07853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top