2

I am fairly new to java having come from a VS2010 background. Currently working on an android app that uses a couple of 3rd party packages of the web - one of which I would like to use the source package for debugging purposes. I cannot seem to get this to work - I initally copied and pasted source jar files to lib directory and had to change import statements but compile still fails with "package does not exist" and "cannot find symbol class". Where do source files need to go within the project? (Using IntelliJ 11)

Thanks in advance.

1
  • u need to add those jar files to classpath Commented Mar 1, 2012 at 10:59

2 Answers 2

4

Typically a source JAR would be used in addition to the normal, binary JAR which contains the classes. The latter is still needed to actually load class definitions. If you removed it, and replaced it with a JAR (which is basically just a Zip file) full of *.java source files, then your application won't be able to find and load the library classes any more.

So to actually answer your question - the source JAR can live anywhere, as you have to tell IntelliJ where it is. Open up the Project Structure window, then on the Dependencies tab find the reference to the binary library in question (you still have it in your project, right?). Then click on the pencil icon to edit it, go to Attach Files or Directories, and then select your source JAR.

IntelliJ will recognise the JAR as full of sources, and will use these to display the code for the classes within the library, as you desire.

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

1 Comment

Excellent. Debugging like a charm. Thanks for a clear, concise and correct answer.
0

Third-party jars should be configured as the module dependencies, you can attach source jars to the libraries to step trough the code or view documentation.

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.