0

I downloaded an API but there is no jar file in it. It has the packages(folders) and the source code. I tried adding this in various ways in Eclipse but still I don't get the "import ...." when I press F2 on the underlined red classname. I have added projects and Jars in Eclipse all the time and it has worked. Since this is the source code should I take any extra steps in order to make it work?

Regards!

2
  • did you tried right click on a directory and then add-to-buildpath? Commented May 8, 2012 at 7:37
  • what I did is that I right clicked on the project in Eclipse when to properties -> Java Build Path -> Liberies tab -> Add external class folder. I also tried it in the Source tab. Is that what you are referring to? Commented May 8, 2012 at 7:43

2 Answers 2

3

If the source is available to you (.java files) you must create a new source folder, then copy the source tree (root package e.g. the folder com or org) into the new source folder just by using a standard file explorer and copy&paste:

enter image description here

Edit: You could add the source files to your existing source folder as well, but I'd avoid that. Best solution would be to create a separate Java project containing just the source files of the external library. You also need proper code management, so that you do not accidentially make changes to the external source files!

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

Comments

1

You may create jar from the classes you have received in API packaging and place that jar into the classpath of the project

Enjoy !!!

3 Comments

This is the better approach, and what you should try to do. However, if you really want to do exactly what you asked for whatever reason, @home answer is the way to go
I see, what is the best way around creating a jar file from source?
The API which you have download will have a build script. You can find build that build.xml using ant and in the build scrit you can find the label or command for creating the jar.

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.