How to include standard jdk library in emacs semantic?

谁说胖子不能爱 提交于 2019-12-03 00:34:13

Starting with CEDET 1.1, Semantic has support for retrieving class information through javap. You need to setup cedet-java-jdk-root variable to JAVA_HOME, and populate semanticdb-javap-classpath variable with list of paths to Java's system jars, like rt.jar, etc.

There is an article (in Russian, but you can get translation) about setting Semantic up for Java completion - please look there for more details.

If you unzip src.zip that is found in $JAVA_HOME you can add a hook for you java mode like this:

(add-hook 'java-mode-hook
  '(lambda ()
     (semantic-add-system-include (getenv "JAVA_HOME") 'java-mode)))

It solves the problem for me with Emacs 23.3 and CEDET 1.1.

Haven't tried CEDET in a while, so I'll blindly ask a few questions that might give insight into your problem.

  1. I assume JDK is on your path, and Emacs can find it?
  2. Since JDK is basically a bunch of jar files without source code, can Semantic parse that? Example: if you make your own Class1.java, compile it to Class1.class and then delete Class1.java, when you write Class2.java and reference some methods from Class1, can Semantic find them?
  3. Have you tried JDEE?
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!