从Java执行时(Windows上)Pdflatex运行崩溃 [英] Pdflatex run crashes when executed from Java (on Windows)

查看:164
本文介绍了从Java执行时(Windows上)Pdflatex运行崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从Java编译下面的Latex文档 时,我的pdflatex运行崩溃:

When I try to compile the below Latex document from Java, my pdflatex run crashes:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\pagestyle{empty}
%
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
    \node [int, pin={[init]above:$v_0$}] (a) {$\frac{1}{s}$};
    \node (b) [left of=a,node distance=2cm, coordinate] {a};
    \node [int, pin={[init]above:$p_0$}] (c) [right of=a] {$\frac{1}{s}$};
    \node [coordinate] (end) [right of=c, node distance=2cm]{};
    \path[->] (b) edge node {$a$} (a);
    \path[->] (a) edge node {$v$} (c);
    \draw[->] (c) edge node {$p$} (end) ;
\end{tikzpicture}

\end{document}

pdflatex不仅会产生一些错误,而且还会冻结.甚至在完成引号之前,日志文件就会在中间被切断(我想总是在同一位置).

pdflatex doesn't just produce some error, but it simply freezes. The log file is cut off in the middle, even before an enclosing quotation mark is completed (but always at the same position, I think).

我使用此Java命令执行pdflatex:

I use this Java command to execute pdflatex:

Runtime.getRuntime().exec(command);
p.waitFor();

执行的命令是:

"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe" -output-directory "C:\Eig\Lehre\Info2\ImagesTemp" "C:\Eig\Lehre\Info2\ImagesTemp\graph.tex"

在命令行中手动执行命令效果很好!另外,当我在乳胶文档中不包含tikz时,Java执行效果很好.这对我来说似乎很奇怪-是否有错误或我缺少什么?

Executing the command by hand in a command line works fine! Also, the Java execution works fine when I don't include tikz in the latex document. This seems quite strange to me - is there some bug or am I missing something?

我在Windows上使用Miktex 2.9和Java 8,我已经在不同的Windows版本上尝试过.

I'm using Miktex 2.9 and Java 8 on Windows, I've tried it on different Windows versions.

推荐答案

此问题可能是由于未捕获进程的输出引起的.您需要读取子进程写入标准输出和标准错误的每个字节,否则系统缓冲区将填满,并且该进程在下次尝试写入内容时将阻塞.

This problem is probably caused by not capturing the output of the process. You need to read every byte written to standard out and standard error by the child process else the system buffer will fill up and the process will block when it next attempts to write something.

这是一个相关的问题:在调用Runtime.exec时捕获标准输出

Here's a related question: Capturing stdout when calling Runtime.exec

其中指向 http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html 了解更多信息.

Which points to http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html for more information.

这篇关于从Java执行时(Windows上)Pdflatex运行崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆