Vim Syntastic Java不了解当前的项目类

时间:2013-05-23 18:28:15

标签: java vim syntastic

在Android项目中使用Vim Syntastic。 (例如com.myproject.project)它不知道在我的项目中但在当前文件之外声明的类。例如以下标志错误:

import com.myproject.project.SomeClass;
...
SomeClass someclass = new SomeClass();

2 个答案:

答案 0 :(得分:10)

看到这篇解决问题的帖子Configure syntastic to work fine with Android projects

方法1:
内部vim编辑器

:SyntasticJavacEditClasspath

然后将以下内容添加到缓冲区窗口

/path-to-your-app/bin/classes  
/path-to-your-android-sdk/platforms/android-19/*.jar

方法2:
将以下内容添加到.vimrc:

let g:syntastic_java_javac_classpath = "/<path-to-your-app>/bin/classes:/<path-to-your-android-sdk>/platforms/android-19/*.jar"

答案 1 :(得分:1)

以下是在linux vim7.4和Syntastic3.7.0-224中为我工作的各种方法的摘要,每个方法都有用。

方法1 - 手动创建.syntastic_javac_config

1. Edit .vimrc and use this syntax:
let g:syntastic_java_javac_config_file_enabled = 1

2. Where you edit your vim files, add this to a file named .syntastic_javac_config

let g:syntastic_java_javac_classpath = '/home/davis/progs/princeton-algos/week1/libs/algs4.jar'

方法2 - 无论您在何处编辑类路径,都可以获得优势。

1. Edit .vimrc and use this syntax:
let g:syntastic_java_javac_classpath = "/home/davis/progs/princeton-algos/week1/libs/algs4.jar"

这会添加jar和

方法3 - 自动生成.syntastic_javac_config文件

1. Edit .vimrc and use this syntax:
let g:syntastic_java_javac_config_file_enabled = 1
2. Edit a java file with vim
3. :SyntasticJavacEditClasspath
When the edit window opens, add the class path without quotes and a newline after each entry the class path. In my case, this is the entry
for the setting includes the current folder as well:
/home/davis/progs/princeton-algos/week1/libs/algs4.jar
.
4 :wq the edit setting window
5. Now the class path is set for syntastic when editing files from that location. If you edit from a new directory, you will need to repeat the process.

除了上面的评论,这个post也有帮助。