How add LT.jar to eclipse

Having a lot a problem finding the .jar files to put into my build path.

The website says this:

If you don’t use Maven (or a similar system), download the stand-alone ZIP instead. You will need the JAR files in the libs directory and everything in the org directory in your classpath.

This is not that clear to someone who is not the best at coding java. I get the lib part, but adding everying in the org directory to your classpath? Why do you guys do it like this? Why not just create one .jar file or something to add like the rest in lib? Instead of having .class files in a class folder?

http://wiki.languagetool.org/java-api

This thread (Languagetool in a simple java application - #20 by jabigelow) has a link to a sample gradle project that uses LT. You can run ‘gradle eclipse’ in it to generate Eclipse project files.

P.S. I wonder if we should move this sample project into git repository?

Still not sure why there is not already a complete .jar made. I do not want to use gradle or maven. So i guess i gotta read up on how to create my own .jar from class flies.

There are files like grammar.xml that some users want to edit, and it’s very inconvenient when they’re hidden in a jar.

No, you just need to add the org directory to your classpath.

I am sorry if this is a very basic question, but how do i do that? I tried going into project build and adding “external class folder”

I don’t know Eclipse, but that sounds correct. The org older needs to be in the classpath, just make sure it’s the org folder itself, not the folders inside that folder.

ok thanks got it now. But like other people in that thread :slight_smile:

I am getting the error:

java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
	at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.IllegalArgumentException: 'en' is not a language code known to LanguageTool. Supported language codes are: xx-XX. The list of languages is read from META-INF/org/languagetool/language-module.properties in the Java classpath. See http://wiki.languagetool.org/java-api for details.
	at org.languagetool.Languages.getLanguageForShortCode(Languages.java:161)
	at org.languagetool.synthesis.en.EnglishSynthesizer.<init>(EnglishSynthesizer.java:61)
	at org.languagetool.rules.en.AbstractEnglishSpellerRule.<init>(AbstractEnglishSpellerRule.java:34)
	at org.languagetool.rules.en.MorfologikAmericanSpellerRule.<init>(MorfologikAmericanSpellerRule.java:34)
	at org.languagetool.language.AmericanEnglish.getRelevantRules(AmericanEnglish.java:46)
	at org.languagetool.JLanguageTool.getAllBuiltinRules(JLanguageTool.java:247)
	at org.languagetool.JLanguageTool.<init>(JLanguageTool.java:167)
	at org.languagetool.JLanguageTool.<init>(JLanguageTool.java:152)
	at application.Main.main(Main.java:34)
	... 11 more
Exception running application application.Main 

I did add the META-INF to classpath but you posted in that thread:

After “zip -r languages.jar META-INF/ org/” you need to add languages.jar to your classpath. How to do that exactly depends on your local environment or IDE.

Where is the languages.jar?

JLanguageTool langTool = new JLanguageTool(new AmericanEnglish());

And it didn’t help? Did you add META-INF itself to the classpath, not the files inside that folder?

The zip command you posted would create that file. But it really shouldn’t matter whether the files are inside a JAR or not.

OK I am a bit confused:

Am I also supposed to add “languagetool.jar” to the classpath as well? This .jar comes with stand-alone download.

I had that in the classpath.

I now removed it and now getting:

	The type org.languagetool.language.English cannot be resolved. It is indirectly referenced from required .class files
	The constructor JLanguageTool(AmericanEnglish) is undefined

When I had that jar in the classpath i was using: import
org.languagetool.language.AmericanEnglish;

but now I would have to just use the package name from the org folder:
languagetool.language.AmericanEnglish;

i got it to work, I did not know that the META folder had to be in same folder as the org folder.