2

i'm trying to use a terminal command latex file.tex to compile a .tex file. My program extracts the absolute path of the .tex file on a String:

public void generateLatex(String path)
{
    String file = path;
    //...compile file;
}

Is there a way to use the command on the given path? I tried using Process

Process p = Runtime.getRuntime().exec(executable + path);
p.waitFor();

But it's not working

1 Answers1

3

You may use Process builder:

ProcessBuilder pb = new ProcessBuilder("latex", "yourlatex.tex")
            .inheritIO()
            .directory(new File("your directory path"));
Process process = pb.start();
process.waitFor();
Kartal Tabak
  • 760
  • 1
  • 7
  • 18