processbuilder

execute batch file remotely java

时光总嘲笑我的痴心妄想 提交于 2019-12-03 16:26:24
I want to execute a bat file located remotely on server \\testserver\someFolderName\test.bat . I am using process builder and wanted to chande the directory with procbuilder.directory(....), but could not succeed. Any help is appreciated. Thanks In the past I've done it quick and dirty with PSExec Just start that from your program as its own process with the required arguments to gain access to the batch on the remote computer. NagendraPrakash Karri This is working code that we are using currently: try { ProcessBuilder launcher = new ProcessBuilder(); Map<String, String> environment = launcher

What can cause Java to keep running after System.exit()?

≯℡__Kan透↙ 提交于 2019-12-03 09:52:43
I have a Java program which is being started via ProcessBuilder from another Java program. System.exit(0) is called from the child program, but for some of our users (on Windows) the java.exe process associated with the child doesn't terminate. The child program has no shutdown hooks, nor does it have a SecurityManager which might stop System.exit() from terminating the VM. I can't reproduce the problem myself on Linux or Windows Vista. So far, the only reports of the problem come from two Windows XP users and one Vista user, using two different JREs (1.6.0_15 and 1.6.0_18), but they're able

Compile and Run Java Program from another Java Program [closed]

无人久伴 提交于 2019-12-02 22:34:03
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . using the CompileAndRun class, i can now compile and run my HelloWorld class. now i want to use this to run a program that requires users input. this may either be a command line argument or input received through stdin. import java.io.File; import java.io.IOException; import java.io.InputStream;

How do I make a JButton run an executable in the same directory?

浪尽此生 提交于 2019-12-02 17:54:36
问题 Okay, I'm trying to make my JButton run an executable in a different directory. It is a previous console application I wrote and I want this button to run the executable. I'm fairly new to the Java programming language but here is my code. import java.util.*; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; public class main { public static void main(final String[] args) throws IOException { JFrame f

Can't execute javac or other command line applications in Java using ProcessBuilder under Windows 7

亡梦爱人 提交于 2019-12-02 16:38:18
问题 I'm trying to execute javac from Java using ProcessBuilder but i get no output and nothing happens. I tried reading the input stream (as there is a bug where the process hangs if i don't read it) but still no results. I originally passed all required parameters to javac but it was not working, so i simplified it down to just javac (which should print the help message). i tried running "C:\Windows\System32\cmd.exe /c C:\\"Program Files\"\Java\jdk1.6.0_23\bin\javac.exe" "C:\\"Program Files\"

Calling an external application (i.e. Windows Calculator) in a GWT web application

风格不统一 提交于 2019-12-02 14:10:30
问题 I am trying to call an external windows application (i.e. calc.exe) when a user clicks on a button in a GWT web application. Is there a way on how to do it? Below are what I have already tried so far: 1.) Tried Runtime.exec and ProcessBuilder but I end up having a GWT compile error Runtime.exec Code: Process winCalc; try { winCalc = Runtime.getRuntime().exec("\"C:/Windows/System32/calc.exe\""); winCalc.waitFor(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e)

Java ProcessBuilder not able to run Python script in Java

我只是一个虾纸丫 提交于 2019-12-02 13:19:40
问题 null from bfr.readLine() However, there is no problem if I run the python file directly on terminal by firing: python C:/Machine_Learning/Text_Analysis/Ontology_based.py The last line in my Python script is >> print(data) The result of the following code is: Running Python starts: First Line: null Picked up _JAVA_OPTIONS: -Xmx512M package text_clustering; import java.io.*; public class Similarity { /** * * @param args * */ public static void main(String[] args){ try{ String pythonPath = "C:

Compile and Run Java Program from another Java Program [closed]

依然范特西╮ 提交于 2019-12-02 13:17:22
using the CompileAndRun class, i can now compile and run my HelloWorld class. now i want to use this to run a program that requires users input. this may either be a command line argument or input received through stdin. import java.io.File; import java.io.IOException; import java.io.InputStream; public class CompileAndRun { public static void main(String[] args) { new CompileAndRun(); } public CompileAndRun() { try { int result = compile("compileandrun/HelloWorld.java"); System.out.println("javac returned " + result); result = run("compileandrun.HelloWorld"); } catch (IOException |

Can't execute javac or other command line applications in Java using ProcessBuilder under Windows 7

南楼画角 提交于 2019-12-02 12:00:15
I'm trying to execute javac from Java using ProcessBuilder but i get no output and nothing happens. I tried reading the input stream (as there is a bug where the process hangs if i don't read it) but still no results. I originally passed all required parameters to javac but it was not working, so i simplified it down to just javac (which should print the help message). i tried running "C:\Windows\System32\cmd.exe /c C:\\"Program Files\"\Java\jdk1.6.0_23\bin\javac.exe" "C:\\"Program Files\"\Java\jdk1.6.0_23\bin\javac.exe" and surrounding the entire path to javac with double quotes but still

executing two commands with process builder

人盡茶涼 提交于 2019-12-02 10:12:46
问题 I'm trying to write a program that compiles another java file from the command prompt. I'm having an issue with it however. At this point, it is successfully executing the first part where it compiles Mocha.java. However, I want it to also execute that file and display what it outputs. It displays nothing. Any suggestions? pb = new ProcessBuilder("javac","Mocha.java"); try { Process shell = pb.start(); OutputStream shellOut = shell.getOutputStream(); shellOut.write("java Mocha".getBytes());