Skip to content
Harri Pitkänen edited this page Dec 19, 2015 · 3 revisions

Installing Java interface for Voikko

Java interface has been part of libvoikko since version 3.2. This is how you can use it.

Installing the native library and dictionary data

You need to have the native libvoikko library available in a place where the OS specific library loading mechanism (System.loadLibrary in fact) will find it. On Linux installation through the package manager will work (on Ubuntu 10.10 installing Finnish language support is enough). On Windows you should place the library in one of the directories within the PATH environment variable.

Dictionaries (voikko-fi or any zhfst speller) should be installed just as with any other application that uses Voikko.

Shipping the native library and dictionaries within one jar package is possible but requires some development effort. The main problem is that these files cannot be used directly from the jar package, they need to be extracted from it before use. JNA already does that for the libraries if it cannot find them using other means but similar trick would need to be developed for dictionaries.

From Git or source package using Eclipse and Maven

  • Install Eclipse.
  • From Git:
    • Within Eclipse select File - New - Project and Checkout projects from Git.
    • Follow the wizard to check out https://github.com/voikko/corevoikko and find the project under libvoikko/java . The wizard should suggest libvoikko as the project name, accept that.
  • From source package:
    • Import the project under subdirectory java.
  • Libvoikko depends on JNA libraries for its operation. Eclipse will use Maven to download and install such dependencies automatically. Check that you don't have any compilation errors in the project.
  • Open your own development project or create one through File - New - Project.
  • Edit your project's Java build path and add libvoikko as a required project to the build path.

Now you should be able to use libvoikko in your Java project. See the libvoikko Javadoc documentation for more info and a simple example.

Without Maven

If you do not want to use Maven or Git you can download

Just make sure that the binary jars for libvoikko and JNA are in your classpath when you run or develop your application.

Documentation

See Javadoc documentation at http://www.puimula.org/htp/testing/voikko-sdk/java/javadoc/

Testing the installation

You can run the unit tests for the Java interface in order to verify that you have all the required stuff installed and working as expected. On Linux, using JUnit and JNA from the distribution:

java -cp libvoikko-3.2-SNAPSHOT.jar:libvoikko-3.2-SNAPSHOT-tests.jar:/usr/share/java/junit4.jar:/usr/share/java/jna.jar org.junit.runner.JUnitCore org.puimula.libvoikko.VoikkoTest org.puimula.libvoikko.VoikkoJnaLatinTest

On Windows, using JUnit and JNA downloaded from the projects' home pages:

java -cp libvoikko-3.2-SNAPSHOT.jar;libvoikko-3.2-SNAPSHOT-tests.jar;junit4.jar;jna.jar org.junit.runner.JUnitCore org.puimula.libvoikko.VoikkoTest org.puimula.libvoikko.VoikkoJnaLatinTest