I have java code corresponding to a policy mining algorithm in a repository and have to execute this using commands on the git bash terminal (Using a Windows PC). I have generated test data and stored it in a file (named temp_check), local to the above mentioned repository. I need help in writing a python program that executes the mining algorithm using the generated input on the git bash terminal on Windows. While the commands mentioned in the bash_script.sh run successfully when entered manually, they throw an error when called through the python program.
PS:- The java code is publicly available and an implementation of a paper. I just need to use this code as a black box in order to get the corresponding output
I have pasted below the contents of the files I have written till now and the corresponding error messages I got.
Python Script
import os
import subprocess
os.environ['PATH'] = 'C:/Program Files/Java/jdk-15.0.1/bin/java.exe' + os.environ['PATH']
bash_command = "./bash_script.sh"
subprocess.run(["bash", "-c", bash_command])
bash_script.sh
#!/bin/bash
# Compile
./compile.sh
# Run using the input file
./run -m ../case-studies/temp_check.abac -verbose >> temp_output.txt
compile.sh (Already present in the repo)
#!/bin/bash
if [ ! -e "bin" ];
then
mkdir bin
fi
cd src/
if [ "${OS}" = "Windows_NT" ]; then
# on Microsoft Windows, use semicolon as a separator in classpath.
javac -cp "../lib/commons-math-2.2.jar;../lib/commons-math3-3.3.jar;." -d ../bin edu/dar/util/*.java
javac -cp "../lib/commons-math-2.2.jar;../lib/commons-math3-3.3.jar;." -d ../bin edu/dar/algo/*.java
else
# on other OSs, use colon as a separator in classpath.
javac -cp "../lib/commons-math-2.2.jar:../lib/commons-math3-3.3.jar:." -d ../bin edu/dar/util/*.java
javac -cp "../lib/commons-math-2.2.jar:../lib/commons-math3-3.3.jar:." -d ../bin edu/dar/algo/*.java
fi;
run (Already present in the repo)
#!/bin/bash
cd bin
java -cp "../lib/commons-math-2.2.jar;../lib/commons-math3-3.3.jar;." edu.dar.algo.Experiment $*
cd ..
The folder structure is as follows:
case-studies/
-- temp_check.abac
lib/
-- commons-math-2.2.jar
-- commons-math3-3.3.jar
src/
bin/
compile.sh
run
python_script.py
bash_script.sh
temp_output.txt
When the python script is run, I get the following error: Error: Could not find or load main class edu.dar.algo.Experiment Caused by: java.lang.ClassNotFoundException: edu.dar.algo.Experiment
But there is no error thrown when commands are entered manually on the gitbash terminal. Thanks in advance.