The java-bridge package


This package offers bindings to the Java Native Interface and a high level interface generator.

low level bindings to the JNI
The low level bindings are located in Foreign.Java.JNI.Safe and Foreign.Java.JNI.Unsafe. When using these bindings you will have to deal with pointers and manage global references manually.
medium level interface
The medium level interface is located in Foreign.Java. It offers an abstraction over the JNI, i.e. you will not have to deal with pointers explicitly nor do you need to manually do conversions between native types and Haskell types. Also references will automatically be released by the Haskell runtime when no longer needed. You will still need to manually lookup classes and methods in order to use them.
high level bindings generator
You can also generate high level bindings using the tools j2hs and hs2j that come along with this package. The tools works in both directions, i.e. you can generate glue code to use existing Java libraries from within Haskell as well as to use Haskell from within Java. This is the most convenient way to deal with a Java library.

It should suffice to do cabal install (or cabal install java-bridge when installing from hackageDB). /You need to have a JDK installed prior to installing this library/.

Setup will try to find the location of your java installation automatically. This is needed in order to load libjvm. Note that this library is loaded dynamically, which means that linking errors might not show up during installation.

You can specify the location of libjvm manually using the environment variable FFIJNI_LIBJVM. This environment variable is consulted by Setup.hs as well as by the library each time libjvm is loaded - which means that you can override the path to libjvm at any time. The function getCompiledLibjvmPath in Foreign.Java.JNI.Safe will tell you what path to libjvm has been set during compilation of the library.

>> FUN WITH (cabal-) FLAGS

The following cabal flags are available to you for configuring your installation:

Build only the Core Modules which offer a direct binding to the Java Native Interface. The core modules are Foreign.Java.JNI, Foreign.Java.JNI.Safe, and Foreign.Java.JNI.Unsafe. This implies NO_TOOLS. Defaults to False.
Do not build the j2hs and hs2j executables. Defaults to False.
Enable a debug build. Defaults to False.
Build the library with special support for Cocoa on Mac OS X (you will not be able to use AWT or Swing without). Defaults to True on Darwin (OS X).
Use the JavaVM framework on MacOS X instead of loading the dynamic library. Defaults to False. Enable this flag if building on your OS X machine fails. Defaults to False.
Build a set of examples. They are prefixed with java- and located along your haskell executables. Defaults to False.

Use for example cabal install -f OSX_FRAMEWORK -f EXAMPLES or cabal configure -f DEBUG.


See HACKING.txt and ISSUES.txt in the tar.gz-package.

[Skip to Readme]


Versions 0.9, 0.99, 0.20130602, 0.20130606, 0.20130606.1, 0.20130606.2, 0.20130606.3
Dependencies base (>=4.5 && <5), bimap (>=0.2.4), containers (>=, cpphs (>=1.16), directory (>=, filepath (>=1.3), hinduce-missingh, hint (>=, java-bridge, mtl (>=2.1.1), multimap (>=1.1), named-records (>=0.5), names (>=0.3.1 && <0.4), split (>=, strings (>=1.1), syb (>=, transformers (>=0.3), unix [details]
License MIT
Author Julian Fleischer <>
Maintainer Julian Fleischer <>
Stability experimental
Category Foreign, Java, JVM, FFI Tools
Uploaded Sat Jun 8 15:07:12 UTC 2013 by JulianFleischer
Distributions NixOS:0.20130606.3
Downloads 1670 total (6 in the last 30 days)
0 []
Status Docs not available [build log]
All reported builds failed as of 2016-12-21 [all 7 reports]


  • Foreign
    • Foreign.Java
      • Foreign.Java.Bindings
        • Foreign.Java.Bindings.HaskellTypes
        • Foreign.Java.Bindings.JavaTypes
        • Foreign.Java.Bindings.Support
      • Foreign.Java.Control
      • Foreign.Java.IO
      • Foreign.Java.JNI
        • Foreign.Java.JNI.Safe
        • Foreign.Java.JNI.Unsafe
      • Foreign.Java.Maybe
      • Foreign.Java.Tutorial
      • Foreign.Java.Utils
      • Foreign.Java.Value


only_coreBuild only the Core Modules which offer a direct binding to the Java Native Interface.DisabledAutomatic
no_toolsDo not build the `j2hs' and `hs2j' executables.DisabledAutomatic
debugEnable a debug build.DisabledAutomatic
osx_guiBuild the library with special support for Cocoa on Mac OS X.EnabledAutomatic
osx_frameworkUse the JavaVM framework on MacOS X instead of loading the dynamic library.DisabledAutomatic
examplesBuild a set of sample executables.DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees

Readme for java-bridge

Readme for java-bridge-0.20130606.1