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

2
  • Does this answer your question? Starting a process in Java? Commented Jan 1, 2020 at 20:40
  • I cant change the path, when I use Process to change the path it does not work Commented Jan 1, 2020 at 20:54

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.