How do I call Frege from Java in Eclipse?

I couldn't find any examples out of this box.

I was able to make a call from Frege to Frege and also from Java to Java in the same project, but I could not get the .java files to recognize the .fr files

What steps should I follow to get the following code to work (in Consumer.java)

My basic setup looks like this:

I installed the eclipse plugin and followed the instructions.

java version "1.7.0_79"

      

Project constructors in the following order:

Frege builder
Java Builder

      

Project path:

* src
      - package tutorials
        -- Consumer.java
        -- FregeProducer.fr

* Referenced Libraries
      - fregec.jar

* JRE System Library
      - ...

      

Consumer:

package tutorials;

public class Consumer {

    public static void main(String[] args) {
        System.out.println("This should be zero: " + FregeProducer.myZero);
    }   
}

      

FregeProducer:

module FregeProducer where

myZero = 0 

      

+3


source to share


1 answer


You are all right as far as I can see. However, it looks like you are using a Java constraint that prevents classes from an unnamed package from being used in a class that is in a named package.

What we have here is an attempt to use something in the class FregeProducer

from within tutorials.Consumer

, and it won't work with Java rules.

You need to specify the module name as tutorials.FregeProducer

. (It's not enough to just put the source file in a directory tutorials

.) Then your immutable Java code should work, IMHO.



You can of course produce Frege classes in any package you want. To do this, you need to move the source file to the appropriate directory and select the appropriate module name. Remember that the module name (and only the module name and neither the source file name nor the location) determines the fully qualified class name of the compiled class:

module Foo where    -- creates class Foo in unnamed Java package
module com.bar.Foo where -- creates class Foo in Java package com.bar

      

+2


source







All Articles