isac-java/src/java-tests/isac/bridge/Isabelle_Isac.java
author Walther Neuper <walther.neuper@jku.at>
Fri, 26 Mar 2021 10:45:05 +0100
changeset 5239 b4e3883d7b66
parent 5229 6bf0e95981e3
permissions -rw-r--r--
reset mathematics-engine to Isabelle2015

note: for this version libisabelle was available,
which connects front-end (Java) and back-end (Isabelle/ML)
     1 /**
     2  * @author Walther Neuper
     3  * Created on Mar 30, 2017
     4  * (c) due to copyright terms
     5  */
     6 
     7 package isac.bridge;
     8 
     9 import java.io.FileNotFoundException;
    10 import java.io.IOException;
    11 import java.io.InputStream;
    12 import java.nio.file.Paths;
    13 import java.util.Properties;
    14 
    15 import edu.tum.cs.isabelle.api.Configuration;
    16 import edu.tum.cs.isabelle.api.Environment;
    17 import edu.tum.cs.isabelle.api.Version;
    18 import edu.tum.cs.isabelle.japi.JPlatform;
    19 import edu.tum.cs.isabelle.japi.JSetup;
    20 import edu.tum.cs.isabelle.japi.JSystem;
    21 import edu.tum.cs.isabelle.setup.Setup;
    22 
    23 /*
    24  * Connect tests with Isac's mathematics engine.
    25  */
    26 public class Isabelle_Isac {
    27   
    28   public static JSystem connect() {
    29     String isabelle_home_ = "";
    30     InputStream inputStream = null;
    31     try {
    32       Properties prop = new Properties();
    33       String propFileName = "./properties/BridgeMain.properties";
    34       inputStream = Isabelle_Isac.class.getClassLoader().getResourceAsStream(propFileName);
    35       if (inputStream != null) {
    36         prop.load(inputStream);
    37       } else {
    38         throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
    39       }
    40       // get the property value and print it out
    41       isabelle_home_ = prop.getProperty("ISABELLE_HOME");
    42         } catch (Exception e) {
    43         System.out.println("Exception: " + e);
    44       } finally {
    45         try { inputStream.close();
    46       } catch (IOException e) { e.printStackTrace(); }
    47       }
    48     Setup setup = new Setup(Paths.get(isabelle_home_), JPlatform.guess(),
    49                new Version("2015"), Setup.defaultPackageName());
    50     Environment env = JSetup.makeEnvironment(setup); // without Duration
    51     Configuration config = Configuration.fromBuiltin("libisabelle_Isac");
    52     return JSystem.create(env, config);    
    53   }
    54 
    55 }