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?
Importing a class in Eclipse
Page 1 of 16 Replies - 112 Views - Last Post: 18 February 2013 - 05:14 AM
Replies To: Importing a class in Eclipse
#2
Re: Importing a class in Eclipse
Posted 17 February 2013 - 02:31 PM
Did the professor specify the class' package?
#3
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.
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.
#4
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
then cut & paste the one provided by your teacher over that newly created one
#5
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
#6
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.
Looks like ill be sticking with JCreator on this, which is a pity.
MIght try out net beans.
#7
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
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|