My question is two parts.
First part:
I am writing a series of latex files, and I would like to compile them.
The command works if I type it manually. so the syntax should be correct. But when I run it from java application, it won't compile.
This code, in Java creates a latex file correctly--as expected.
File latexFile = fileChooser.showSaveDialog(window.stage);
if (latexFile != null) {
try {
writeContentToFile(content, latexFile);
} catch (IOException ex) {
Logger.getLogger(DocumentViewPort.class.getName()).log(Level.SEVERE, null, ex);
}
}
I can compile the generated file in the command line if I type pdflatex
and then add the file path and get a PDF file
.
but it does not seem to work when doing it from java itself like in here:
try {
Runtime.getRuntime().exec( "pdflatex " + latexFile.getPath());
} catch (IOException ex) {
Logger.getLogger(FileAndContentCreation.class.getName()).log(Level.SEVERE, null, ex);
}
any ideas why? I tried to read online on many places, I can't find out what part is the problematic one. Any help would be greatly appreciated. Thanks.
Second part
My second part of the question is changing the directory, I am using:
Runtime.getRuntime().exec( "cd " + myNewdirectory.getPath());
But it fails with an error=2
Any ideas how to change the current directory?