【问题标题】:How to compile a LaTex file from Java program in Mac如何在 Mac 中从 Java 程序编译 LaTex 文件
【发布时间】:2020-01-01 20:36:51
【问题描述】:

我正在尝试使用终端命令 latex file.tex 来编译 .tex 文件。我的程序在字符串上提取 .tex 文件的绝对路径:

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

有没有办法在给定路径上使用命令?我尝试使用进程

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

但它不起作用

【问题讨论】:

  • 这能回答你的问题吗? Starting a process in Java?
  • 我无法更改路径,当我使用 Process 更改路径时它不起作用

标签: java macos latex pdflatex


【解决方案1】:

您可以使用流程构建器:

ProcessBuilder pb = new ProcessBuilder("latex", "yourlatex.tex")
            .inheritIO()
            .directory(new File("your directory path"));
Process process = pb.start();
process.waitFor();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多