简体   繁体   中英

using java source package

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.

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.

第三方jar应当配置为模块依赖项 ,您可以将源jar附加到库以逐步浏览代码或查看文档。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM