blue-sky blue-sky - 2 months ago 9x
Java Question

How to run generated frege java code on jvm?

hello world in haskell frege : :

module Hello where

main args = do
putStrLn "Hello, World!"

This code generates :

Source code is in UTF-8 encoding. The following symbols may appear, among others:
α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω « • ¦ » ∀ ∃ ∷ … → ← fi fl ƒ
If you can't read this, you're out of luck. This code was generated with the frege compiler version 3.24.80
from Do not edit this file! Instead, edit the source file and recompile.

import frege.run8.Func;
import frege.run8.Lazy;
import frege.run8.Thunk;
import frege.runtime.Meta;
import frege.runtime.Phantom.RealWorld;
import frege.Prelude;
import frege.control.Category;
import frege.control.Semigroupoid;
import frege.prelude.Maybe;
import frege.prelude.PreludeArrays;
import frege.prelude.PreludeBase;
import frege.prelude.PreludeIO;
import frege.prelude.PreludeList;
import frege.prelude.PreludeMonad;
import frege.prelude.PreludeText;

source="", time=1470398249962L, jmajor=1, jminor=8,
"frege.Prelude", "frege.prelude.PreludeArrays", "frege.prelude.PreludeBase", "frege.prelude.PreludeIO",
"frege.prelude.PreludeList", "frege.prelude.PreludeMonad", "frege.prelude.PreludeText", ""
nmss={"Prelude", "PreludeArrays", "PreludeBase", "PreludeIO", "PreludeList", "PreludeMonad", "PreludeText", "Regexp"},
symas={}, symcs={}, symis={}, symts={},
symvs={@Meta.SymV(offset=20, name=@Meta.QName(pack="Hello", base="main"), stri="s(u)", sig=1, depth=1, rkind=49)},
@Meta.Tau(kind=2, suba=0, tcon={@Meta.QName(kind=0, pack="frege.prelude.PreludeBase", base="[]")}),
@Meta.Tau(kind=2, suba=0, tcon={@Meta.QName(kind=0, pack="frege.prelude.PreludeBase", base="StringJ")}),
@Meta.Tau(kind=2, suba=0, tcon={@Meta.QName(kind=0, pack="frege.prelude.PreludeBase", base="Char")}),
@Meta.Tau(kind=0, suba=1, subb=2), @Meta.Tau(kind=0, suba=0, subb=3),
@Meta.Tau(kind=2, suba=0, tcon={@Meta.QName(kind=0, pack="frege.prelude.PreludeBase", base="ST")}),
@Meta.Tau(kind=2, suba=0, tcon={@Meta.QName(kind=0, pack="frege.prelude.PreludeBase", base="RealWorld")}),
@Meta.Tau(kind=0, suba=5, subb=6),
@Meta.Tau(kind=2, suba=0, tcon={@Meta.QName(kind=0, pack="frege.prelude.PreludeBase", base="()")}),
@Meta.Tau(kind=0, suba=7, subb=8)
rhos={@Meta.Rho(rhofun=false, rhotau=4), @Meta.Rho(rhofun=false, rhotau=9), @Meta.Rho(sigma=0, rhotau=1)},
sigmas={@Meta.Sigma(rho=0), @Meta.Sigma(rho=2)}, exprs={@Meta.Expr()}
final public class Hello {

final public static Func.U<RealWorld, Short> $main(final Lazy<PreludeBase.TList<String/*<Character>*/>> arg$1) {
return Prelude.putStrLn("Hello, World!");

public static void main(final java.lang.String[] argv) {
try { = argv;


} finally {; }

I then compile the generated java code with no error :

javac -cp frege3.jar build/Hello.class

I then attempt to run the code :

cd build
java Hello

But this returns an error :

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: frege/run8/Lazy
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(
at java.lang.Class.privateGetMethodRecursive(
at java.lang.Class.getMethod0(
at java.lang.Class.getMethod(
at sun.launcher.LauncherHelper.validateMainClass(
at sun.launcher.LauncherHelper.checkAndLoadMain(
Caused by: java.lang.ClassNotFoundException: frege.run8.Lazy
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 7 more

How to run the generated frege java code on jvm ?

I'm using java8


You need to add frege3.jar in your classpath also when you launch the command, so try this:

java -cp .:frege3.jar Hello

Assuming that frege3.jar and Hello.class are both in the current directory