Search code examples
vimjavacsyntastic

Syntastic Not Passing Classpath to Javac


I'm working in Windows, trying to use gVIM with Syntastic for a Java project, and I can't seem to get the plugin to send the Java classpath to the compiler.

Here's my _vimrc configuration:

let g:syntastic_java_checkers=['java']
let g:syntastic_java_javac_config_file_enabled = 1

This configures Syntastic to read the classpath from a file called .syntastic_javac_config in my working directory, which I have filled out with the following information (absolute paths abridged for readability):

let g:syntastic_java_javac_classpath = '<project root>\build\classes\main;<project root>\build\resources\main;<project root>\build\classes\test;<project root>\build resources\test'

The configuration above appears to be correct, in that I can run the command :SyntasticJavacEditClasspath and it shows the classpath I have configured in the config file. For some reason, though, the classpath is never being passed to javac. If I run the procmon.exe tool in Microsoft's SysinternalsSuite, I see javac being called with the following command line (where <working file> is an absolute path):

javac -Xlint -d %AppData%\Local\Temp\1\vim-syntastic-javac <working file>

Notably absent is the -cp parameter to configure the classpath. The result is that all of my imports to other classes I've written generate failures, as well as every reference to those classes in my code. Kind of useless.

I'm hoping someone can offer an idea about what might be wrong here. I've looked at the javac.vim file in Syntastic, but nothing sticks out as an obvious source of the problem. If anyone knows a way to step through the Vimscript, I would consider that a win as well.


Solution

  • I was able to step through using Vim's :debug facility, and found that the javac syntax checker was not splitting the classpath as I expected, looking for \n as a path separator rather than the path separator native to the OS (; in Windows, : on *nix). Specifying the classpath in .syntastic_javac_config in this manner solved the problem.

    I'll do a little more research to determine if the problem is due to a misunderstanding on my end, or a bug in Syntastic, and I'll file a bug report if necessary.