Hey community!
I would like to run the program SPASS (see https://www.mpi-inf.mpg.de/departmen...over/download/) from Java. The following code should run it and print its output; well it at least does so, when replacing the literal "SPASS" by "gedit" for instance:
Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class EntryPoint {
public static void main(String[] args) throws IOException, InterruptedException {
String cmd = "SPASS";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
pr.waitFor();
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line = buf.readLine()) != null) {
System.out.println(line);
}
}
}
In case you are familiar with jshell, you can minimise the example to the following:
Code:
$ jshell
| Welcome to JShell -- Version 10.0.1
| For an introduction type: /help intro
jshell> var run = Runtime.getRuntime();
run ==> java.lang.Runtime@6f7fd0e6
jshell> run.exec("SPASS");
| java.io.IOException thrown: Cannot run program "SPASS": error=2, No such file or directory
| at ProcessBuilder.start (ProcessBuilder.java:1128)
| at ProcessBuilder.start (ProcessBuilder.java:1071)
| at Runtime.exec (Runtime.java:635)
| at Runtime.exec (Runtime.java:459)
| at Runtime.exec (Runtime.java:356)
| at (#2:1)
In ~/.bashrc I registered the program via an alias:
Code:
alias SPASS='~/Desktop/SPASS-3.5/SPASS'
which does work, when run on the terminal
Code:
$ SPASS
/home/jfd/Desktop/SPASS-3.5/SPASS V 3.5
Usage: SPASS [options] [<input-file>]
Possible options:
Auto Stdin Interactive Flotter
SOS Splits SplitMinInst Memory
TimeLimit DocSST DocProof DocSplit
Loops PSub PRew PCon
PTaut PObv PSSi PSST
PMRR PUnC PAED PDer
PGiven PLabels PKept PProblem
PEmptyClause PStatistic FPModel FPDFGProof
PFlags POptSkolem PStrSkolem PBDC
PBInc PApplyDefs Select RInput
Sorts SatInput WDRatio PrefCon
FullRed FuncWeight VarWeight PrefVar
BoundMode BoundStart BoundLoops ApplyDefs
Ordering CNFQuantExch CNFOptSkolem CNFStrSkolem
CNFProofSteps CNFSub CNFCon CNFRedTimeLimit
CNFRenaming CNFRenMatch CNFPRenaming CNFFEqR
IEmS ISoR IEqR IERR
IEqF IMPm ISpR IOPm
ISPm ISpL IORe ISRe
ISHy IOHy IURR IOFc
ISFc IUnR IBUR IDEF
RFRew RBRew RFMRR RBMRR
RObv RUnC RTer RTaut
RSST RSSi RFSub RBSub
RAED RCon TDfg2OtterOptions EML
EMLAuto EMLTranslation EML2Rel EMLTheory
EMLFuncNdeQ EMLFuncNary EMLFFSorts EMLElimComp
EMLPTrans TPTP rf
Do I have to register the program in Ubuntu as an actual program in the application management? I would like to run my program on any OS with a prerequirement of a runnable "SPASS" macro pointing to the program, so giving a path is a bad option, but it remains an alternative if nothing else works.
Thank you in advance!
Bookmarks