6 Replies - 278 Views - Last Post: 18 February 2013 - 05:14 AM Rate Topic: -----

#1 ddublya  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 16-October 12

Importing a class in Eclipse

Posted 17 February 2013 - 02:26 PM

I cannot for the life of me import a class file that has been provided by our Professor.
We do not have the java file just the class as we need to use it in our main.
With uni we use JCreator and the class file just needs to be in the same folder as the working directory.
In Eclipse it appears this is not the case, I have searched and I know about the build path but it doesnt seem to be working.

Any ideas?
Is This A Good Question/Topic? 0
  • +

Replies To: Importing a class in Eclipse

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: Importing a class in Eclipse

Posted 17 February 2013 - 02:31 PM

Did the professor specify the class' package?
Was This Post Helpful? 0
  • +
  • -

#3 ddublya  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 16-October 12

Re: Importing a class in Eclipse

Posted 17 February 2013 - 02:37 PM

Not sure what specify is but we were provided a class file that was contained in the working folder, as in date.class.
The main java runs just fine and utilises the class in JCreator - I use a MAC at home so I use Eclipse and cannot get the program to read the class.
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Importing a class in Eclipse

Posted 17 February 2013 - 02:38 PM

Simply ceate a class with the same name and package in Eclipse
then cut & paste the one provided by your teacher over that newly created one
Was This Post Helpful? 1
  • +
  • -

#5 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: Importing a class in Eclipse

Posted 17 February 2013 - 02:50 PM

Quote

Not sure what specify is but we were provided a class file that was contained in the working folder, as in date.class.

Copy the provided .class file to a folder.
In Eclipse's Package Explorer, right click the source folder of the project you're trying to import the file to.
Select Import
Select General, File System, Next
Browse/Navigate to and select the folder the .class file was saved to, don't open the folder. Select OK.
Select the whole folder in the left pane or the desired file(s) from the right pane of the File System Dialog.
Select Finish.

I can't try this to make sure it works in your situation, but it should.

This post has been edited by GregBrannon: 17 February 2013 - 02:51 PM

Was This Post Helpful? 0
  • +
  • -

#6 ddublya  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 16-October 12

Re: Importing a class in Eclipse

Posted 18 February 2013 - 04:54 AM

That' didn't work. I have loaded JCreator on my virtualbox and its working fine.
Looks like ill be sticking with JCreator on this, which is a pity.
MIght try out net beans.
Was This Post Helpful? 0
  • +
  • -

#7 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2717
  • View blog
  • Posts: 11,428
  • Joined: 20-September 08

Re: Importing a class in Eclipse

Posted 18 February 2013 - 05:14 AM

Quote

I cannot for the life of me import a class file that has been provided by our Professor.


Open a command line in the same directory as the class file. Assuming 'X.class', what do you get from the following command?

javap X

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1