participate


New To Java - how to import a .class in eclipse?
<<   Back to Forum  |   Give us Feedback
This topic has 9 replies on 1 page.
jinxjinxjinx
Posts:42
Registered: 1/6/05
how to import a .class in eclipse?   
May 30, 2005 2:51 PM

 
I have a .class file w/ out the source, and im tiring to import that into my project.

So I go to import->File System and check the .class file. It shows up in my project but when I try to instantiate it I get a "can not be instantiated to a type" error.

any thoughts?
this is happening to a lot of people in my course.
thanks!
 
sp00ker
Posts:49
Registered: 4/10/05
Re: how to import a .class in eclipse?   
May 30, 2005 8:22 PM (reply 1 of 9)  (In reply to original post )

 
Goto to project properties -> java build path -> libraries -> add external class folder.

Add the folder that contains the class here.
 
jinxjinxjinx
Posts:42
Registered: 1/6/05
Re: how to import a .class in eclipse?   
May 30, 2005 9:25 PM (reply 2 of 9)  (In reply to #1 )

 
yay! that works thanks!
 
snowkid
Posts:2
Registered: 1/18/06
Re: how to import a .class in eclipse?   
Jan 18, 2006 6:50 PM (reply 3 of 9)  (In reply to #1 )

 
My project file was made on existing folder that had files in it. When i go to do what you said, and add it, it says i have a "Duplicate folder" and it won't let me add it. Am i doing something wrong?
 
kablair
Posts:2,045
Registered: 4/26/03
Re: how to import a .class in eclipse?   
Jan 18, 2006 7:14 PM (reply 4 of 9)  (In reply to #3 )

 
Then you're either adding a folder that is already there or you're trying to use a name that is already taken in that project.
 
snowkid
Posts:2
Registered: 1/18/06
Re: how to import a .class in eclipse?   
Jan 18, 2006 7:38 PM (reply 5 of 9)  (In reply to #4 )

 
hmm...that makes sense.

when i go to add that class folder, there is only one folder there for me to choose, and that is my project folder.
 
gejza
Posts:1
Registered: 8/9/06
Re: how to import a .class in eclipse?   
Aug 9, 2006 1:15 PM (reply 6 of 9)  (In reply to #1 )

 
Hi,

i tried that what you sad, but my eclipse can't import that class.

So: I have eclipse 3.1, and i would like to import a class (without source). I develop at the moment a J2ME project with eclipse.
The class what i want to import is in a package, so i must to import like this: import net.jscience.math.kvm.MathFP;

Can you tell me how in the hell can i this class to import?
(I tried about 6 hours long, and i got some result, but not the really perfect.)
When i make this subdirectory structure (what is in the import line) into my project, then in eclipse work the auto completing, 'till the class name. :-/. But the class is there. Egal i add an external class folder, i got always the same result.
Please help me, because my brain at the moment wants to explode.

Thanks a lot.
 
Snow_White_Favorite_Dwarf
Posts:2
Registered: 2/16/07
Re: how to import a .class in eclipse?   
Feb 16, 2007 2:00 PM (reply 7 of 9)  (In reply to #6 )

 
Hi,

If you want to import a ".class", file or folder into your project.

Then go do one of the 2 techniques.
Select the root folder of the project by left clicking on it.

1) From the menu [File->import->General->File system]

2) With the right click [import->import->General->File system]

All you have to do is import the folder with the files. Or simply import the entire file
system with the documentation. If you want to place the class in a specific folder just drag the class into an already made package or folder.
 
borgrodrick
Posts:1
Registered: 2/3/08
Re: how to import a .class in eclipse?   
Feb 3, 2008 1:48 PM (reply 8 of 9)  (In reply to #7 )

 
When I import a class and tries to open it it tells me "Source not found", "There is no source file attached to the class file"
 
DarrylBurke
Posts:15,569
Registered: 7/2/07
Re: how to import a .class in eclipse?   
Feb 3, 2008 8:43 PM (reply 9 of 9)  (In reply to #8 )

 
Surprising, considering that you managed to reopen a 3? year old topic that's been dead for a year.

So how exactly do you expect to open a .class file when you don't have the source?

db
 
This topic has 9 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 25
  • Guests : 129

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums