Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing class/java files in Eclipse

Tags:

java

eclipse

I'm new to Java Programming using Eclipse, so would really appreciate your help for this question.

I have doing Java programming both at college and home. At home, I have all my Java classes under a single project-(Java Reference). Now, in college, the java programs are compiled on the lab machines. And I would really like to have all these programs in a single project, on my laptop.

I had recently copied all the .class and .java files from the programs we did in college labs, so I could have them under the "Java Reference" project in my laptop. I copied the .class and .java files under the "bin" and "src" folders of the java project, on my laptop. However, I don't see anyway to import them through Eclipse.

From what I read here, it looks like having an entire project(created somewhere else) could be copied into one place, through the import option, but in my case, I only have the .class and .java files.

like image 216
Manish Giri Avatar asked Nov 24 '13 02:11

Manish Giri


People also ask

How do I Import a .class file into Eclipse?

In Eclipse, to import a single class, you may clicked on the class and press shortcut key “ Ctrl + Space ” to prompt all the available classes to import.

Can classes be imported in Java?

Classes in the same project can be imported into any other class in the same project without any import statement in the particular class of the project.


1 Answers

First, you don't need the .class files if they are compiled from your .java classes.

To import your files, you need to create an empty Java project. They you either import them one by one (New -> File -> Advanced -> Link file) or directly copy them into their corresponding folder/package and refresh the project.

like image 123
m0skit0 Avatar answered Oct 03 '22 19:10

m0skit0