0

how do I add an existing class into an existing project. I've got the file "Something.class" and in the code I do a

something window = new Something();

But it remains underlined in red. Does someone know how do I fix this?

Thanks!!

0

4 Answers 4

1

If it's not already part of your workspace, it should be enough just to File -> Import and then find the class you want included. If it's already part of the workspace, then Tommi's suggestion should do it.

Sign up to request clarification or add additional context in comments.

1 Comment

Hmm, ctrl->space doesn't seem to do what I thought it did. You may have better luck by hitting ctrl-shift-O (or right clicking inside your code editor window and going to Source -> Organize Imports)
1

Also note, that Java is case sensitive. So in

something window = new Something();

something and Something are two different classes :)

Comments

0

You need to import the class into the referencing class. Ctrl + Space (while highlighting the classname) should do the trick in Eclipse.

1 Comment

It's still giving me an error. I've imported the library in project properties->java build path->Libraries->Add external class Folder and then selecting the directory containing the class, but to no avail....
0

You need to add the jar file that has the class something to your project and import it your class.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.