Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Syntastic Java Unaware of Current Project Classes

Using Vim Syntastic with an android project. (e.g. com.myproject.project) It's not aware of classes declared within my project but outside of the current file. e.g. the following flags errors:

import com.myproject.project.SomeClass;
...
SomeClass someclass = new SomeClass();
like image 892
lorean Avatar asked May 23 '13 18:05

lorean


2 Answers

Saw this post Configure syntastic to work fine with Android projects which solve the problem:

Method 1:
Inside vim editor

:SyntasticJavacEditClasspath

Then add the following to the buffer window

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

Method 2:
Add the following to the .vimrc:

let g:syntastic_java_javac_classpath = "/<path-to-your-app>/bin/classes:/<path-to-your-android-sdk>/platforms/android-19/*.jar"
like image 132
ken Avatar answered Sep 28 '22 06:09

ken


Here is a summary of the various methods which worked for me in linux vim7.4 and Syntastic3.7.0-224 with credit to each.

Method 1 - manual creation of .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'

Method 2 - advantage no matter where you edit the class path is known.

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

This adds the jar and

Method 3 - Automatic generation of .syntastic_javac_config file

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.

Besides the comments above, this post also helped.

like image 23
netskink Avatar answered Sep 28 '22 06:09

netskink