LanguageToolCheck not working

Hi:

I am trying to install the plugin for vim.

When I type :LanguageToolCheck in vim I get the following error:

Error detected while processing function 10_LanguageToolCheck:
line 32:
Command [java -jar /$HOME/LanguageTool-2.3/languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_
QUOTES -l en --api /var/folders/19/cg8rhm217x73lsj73y4h04_w0000gn/T/vJlAxKy/3] failed with error: 1

P.S:
I have java 7.

It means that vim failed to launch LanguageTool in command line somehow. Probably either LanguageTool is not correctly installed, or vim’s variable g:languagetool_jar which indicates the location of the command line LanguageTool jar file (languagetool-commandline.jar) is incorrect.

It’s odd that there is a / (slash) in front of /$HOME in your message. But I don’t think that it should cause it to fail anyway.

Can you first try from the command line to check that LanguageTool works. Something like this should work:

$ echo “This is is a test.” |
java -jar $HOME/LanguageTool-2.3/languagetool-commandline.jar -c utf-8 -l en-US

It should report something like this:

Expected text language: English (US)
Working on STDIN…
1.) Line 1, column 6, Rule ID: ENGLISH_WORD_REPEAT_RULE
Message: Possible typo: you repeated a word
Suggestion: is
This is is a test.
^^^^^
Time: 287ms for 1 sentences (3.5 sentences/sec)

Note also that for LanguageTool to signal spelling errors in English, the language must be something like en-US or en-GB. In your message, I notice that the language was only “en”, which will cause LT to signal only grammar errors but not spelling errors. The correct language will be used if you set the spelling language in Vim with something like:

:set spelllang=en_us

Alternatively, you can also put something like this in your ~/.vimrc file:

:let g:languagetool_lang=en-US

Thanks for your help. I added the language type in vimrc. I get the following when I write the command:

$ echo “This is is a test.” | \
java -jar $HOME/LanguageTool-2.3/languagetool-commandline.jar -c utf-8 -l en-US

Exception in thread “main” java.lang.UnsupportedClassVersionError: org/languagetool/commandline/Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

It looks like you’re not using java-7. What do you see if you type…

$ java -version

For me, it outputs:

java version “1.7.0_25”
OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

See also: jvm - How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version - Stack Overflow

I have also just updated the LanguageTool plugin for Vim so that it should now show the stderr output of the java command in case it somehow failed. It should help to diagnose this kind of issues for other users. Updated plugin is available at:

http://www.vim.org/scripts/script.php?script_id=3223

Alright, now I understand. I had checked my java version from system settings and it was saying that I have java 7, but the command line gives me 1.6. I will update java and test it again. Thanks a lot.

Ok I update Java and it is working, awesome. Just a question, after LanguageToolCheck command is there any way to confirm or reject the errors? For example if I have the following sentence:

“this is ann example”

It will give me two errors, one that this should be capitalized and the other one is about ann. Is there is any way to apply, or ignore the errors without manually changing them?