processbuilder

JavaFX FXML communication between Application and Controller classes

浪子不回头ぞ 提交于 2019-12-18 18:26:34
问题 I am trying to get and destroy an external process I've created via ProcessBuilder in my FXML application close, but it's not working. This is based on the helpful advice Sergey Grinev gave me here. I have tried running with/without the "// myController.setApp(this);" and with "// super.stop();" at top of subclass and at bottom (see commented out/in for that line in MyApp), but no combination works. This probably isn't related to FXML or JavaFX, though I imagine this is a common pattern for

Java execute process on linux

孤人 提交于 2019-12-18 07:01:23
问题 I've been struggling for a while now with this problem and i can't seem to fix it. i already have tried different approaches (Runtime.exec(), ProcessBuiler) but none seem to work. This is my issue. I have a laptop which is always on. This laptop runs a java tool connected to an arduino via usb to turn on and off the lights in the house. i have created this program myself, therefore i'm also doing some regular maintenance work on it. Recently i have added a button to restart the program from

ProcessBuilder vs Runtime.exec()

只谈情不闲聊 提交于 2019-12-18 04:48:10
问题 I'm trying to create a frontend app in Java to handle batch SVG conversions using Inkscape's command line feature. I'm taking and updating the code from https://sourceforge.net/projects/conversionsvg/. The way the original developer handled calling Inkscape by Runtime.getRuntime().exec(String) . The issue I'm running into is some inconsistencies between using methodA and methodB. I created a simple java test project to demonstrate the different actions being performed. CallerTest.java package

Executing another application from Java

北战南征 提交于 2019-12-16 22:46:10
问题 I need to execute a batch file which executes another Java application. I don't care whether it executes successfully or not and I don't have to capture any errors. Is it possible to do this with ProcessBuilder? What are the consequences if I do not capture errors? However, my requirement is just to execute another Java application. 回答1: The Runtime.getRuntime().exec() approach is quite troublesome, as you'll find out shortly. Take a look at the Apache Commons Exec project. It abstracts you

Java Programming: call an exe from Java and passing parameters

坚强是说给别人听的谎言 提交于 2019-12-16 20:17:34
问题 I'm figuring out a mechanism to call an exe from Java and passing in specific parameters. How can I do? Process process = new ProcessBuilder("C:\\PathToExe\\MyExe.exe").start(); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; System.out.printf("Output of running %s is:", Arrays.toString(args)); while ((line = br.readLine()) != null) { System.out.println(line); } The previous code works. But

Multiple execution of a ProcessBuilder in a Java program

放肆的年华 提交于 2019-12-13 21:38:22
问题 I want to use ProcessBuilder in a Java program which will be used many times in the same program. This code snippet is checked for every record in the database. If only one record satisfies the constraints like start time/end time then I don't have any problem, but if two records satisfies any of these constraints then first record, it executes the commands in the processbuilder and redirects output to logfile. Log but the second record, it doesn't executes the commands in the processbuilder

Escape space in ProcessBuilder

筅森魡賤 提交于 2019-12-13 19:53:10
问题 I am not able to execute the following code in Eclipse: public static void main(String[] arg){ String path="C:\\Users\\my dir\\SendMailPS.ps1"; ProcessBuilder processBuilderObject = new ProcessBuilder("powershell",path); try { processBuilderObject.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } But I am able to execute it if path is as C:\\Users\\SendMailPS.ps1 . So the problem is with spaces, how can I solve this? Edit: I tried like this as well

Start GitLog with Java Process Builder

蹲街弑〆低调 提交于 2019-12-13 17:18:36
问题 I try to start a GitLog command via Processbuilder in Java. GitLog Command : git --git-dir=C:/Users/User/Code/code1/git/.git log --pretty=format:"%H \"%an\" %ad \"%s\"" --numstat --date=short This is my code. The Path is the path to the git dir. I hardcoded the gitpath to the git dir for testing. public void createGitLog( Path path ) { try { String gitpath = "--git-dir=C:/Users/User/Code/code1/git/.git"; String options = "--pretty=format:\"%H \\\"%an\\\" %ad \\\"%s\\\"\" --numstat --date

Not able to execute an exe file from java using ProcessBuilder

匆匆过客 提交于 2019-12-13 14:47:09
问题 I am making a project to run C, C++ and Java, from within Java code itself. It works absolutely fine for Java, and the problem is faced when compiling and executing C and C++ files. I got my compilation right with this code and I can get the executable file generated in my specified path. But now when I run the executable binary from ProcessBuilder I get an error saying that 'file was not found'. Please see to the code and tell me what is going wrong and where?? public void processCode(String

How to run a proccess completely seperate in Java

好久不见. 提交于 2019-12-13 14:24:59
问题 I have a Java program which starts another process with ProcessBuilder like the following: String commands[] = {"ruby", "/home/scripts/script.rb"}; ProcessBuilder builder = new ProcessBuilder(commands); Map<String,String> map = builder.environment(); map.put("TYPE", "sometype"); try { builder.start(); } catch (IOException e) { e.printStackTrace(); } Some time after the process starts executing (a small Ruby Script which should not terminate) the Java program exits. The problem is, once the