processbuilder

How to connect to Oracle as “SYS” from SQL*Plus in Java

房东的猫 提交于 2019-12-02 09:17:31
问题 I want to connect to Oracle as SYS from SQL*Plus in Java. But I am not able to connect. But I am able to connect as user named SCOTT . My code snippet is as follows: public static void test_script () { String fileName = "@t.sql"; //t.sql contains "show user" command String sqlPath = "D:\\"; String sqlCmd = "sqlplus"; // String arg1 = "scott/tiger@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname)(Port=PORT ID))(CONNECT_DATA=(SID=SID)))"; String arg1 = "sys as sysdba/tiger@(DESCRIPTION=

executing two commands with process builder

那年仲夏 提交于 2019-12-02 07:10:24
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()); shellOut.close(); InputStream shellIn = shell.getInputStream(); String response = IOUtils.toString

Can't run program with ProcessBuilder, runs fine from command line

为君一笑 提交于 2019-12-02 05:31:38
On linux (debian), I can run this command: /usr/lib/jvm/jdk1.7.0_21/bin/java -jar ~/myjar.jar ".*" I am trying to run it from a Java program instead with: ProcessBuilder pb = new ProcessBuilder(java, "-jar", "~/myjar.jar", "\".*\""); System.out.println(pb.command()); prints the following, as expected: [/usr/lib/jvm/jdk1.7.0_21/bin/java, -jar, ~/myjar.jar, ".*"] However I don't get the same output from the program (it runs but the ouput looks as if the ".*" argument is not properly taken into account). Any ideas why it doesn't work? Note: the same code works fine on Windows. Looks like the

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

寵の児 提交于 2019-12-02 04:36:32
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) { e.printStackTrace(); } Runtime.exec Code - GWT Compile Error: Rebinding dir.ClientGinjector Checking

The correct way to handle Process streams

蹲街弑〆低调 提交于 2019-12-02 04:36:16
Can anyone clarify me if the below procedure is correct way to handle streams of process without any stream buffer full and blocking problems I'm invoking external program from java program, I'm using ProcessBuilder to build the process and after I perform Process gpgProcess = processBuilder.start(); I'm handling the process using a method String executionResult = verifyExecution(gpgProcess); and in my method i'm trying to handle the process streams private String verifyExecution(Process gpgProcess) throws IOException, InterruptedException { String gpgResult = null; BufferedReader stdOut = new

Using ProcessBuilder to execute a python script with command line options

不打扰是莪最后的温柔 提交于 2019-12-02 03:46:26
问题 in order to execute a python script(which has several command line parameters) from Java, I am trying to use is the following java code String[] command = {"script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31 val_32", }; ProcessBuilder probuilder = new ProcessBuilder( command ); Process process = probuilder.start(); For instance I intend to execute the following command: ./script.py run -arg1 val1 -arg2 val2 -arg3 val_31 val_32 note that the parameter arg3 takes a list of

Java ProcessBuilder: environment set correctly but still command not found

限于喜欢 提交于 2019-12-02 03:27:48
问题 I am having troubles with Java's ProcessBuilder on an Eclipse plugin I'm developing. I correctly set the environment before calling the start() method, but when I run the program, it always returns a command not found error. When I call the command via command line it works perfectly. When I start the eclipse with the environment as I require, the command is found and the program works fine. Only when I set the environment programatically, the program fails. Here is what I have:

ProcessBuilder does not stop

旧时模样 提交于 2019-12-02 02:41:53
问题 I am trying to decode an mp3 file to a wav file by using the ProcessBuilder class under Linux. For some reason the process does not stop so that I have to cancel it manually. Could somebody give me a hint on this. I think that the quoted code is very easy to reproduce: import java.io.*; public class Test { public static void main(String[] args) { try { Process lameProcess = new ProcessBuilder("lame", "--decode", "test.mp3", "-").start(); InputStream is = lameProcess.getInputStream();

ProcessBuilder does not stop

吃可爱长大的小学妹 提交于 2019-12-02 01:58:46
I am trying to decode an mp3 file to a wav file by using the ProcessBuilder class under Linux. For some reason the process does not stop so that I have to cancel it manually. Could somebody give me a hint on this. I think that the quoted code is very easy to reproduce: import java.io.*; public class Test { public static void main(String[] args) { try { Process lameProcess = new ProcessBuilder("lame", "--decode", "test.mp3", "-").start(); InputStream is = lameProcess.getInputStream(); FileOutputStream fileOutput = new FileOutputStream("test.wav"); DataOutputStream dataOutput = new

Java ProcessBuilder with multiple params with spaces

让人想犯罪 __ 提交于 2019-12-02 01:27:16
问题 I know that there is a lot of solved questions regarding executing processes from java.But I am unable to solve my problem using answers provided. I am trying go create postgresql database backup from java application. I use following code //ProcessBuilder probuilder = new ProcessBuilder(new String[]{"cmd","/c","D:/PostgreSQL 8.2/bin/pg_dump.exe","-U","usr","-i","-h","localhost","-p","5432","-F","c","-b","-f","D:/backup test/backups/test_27-1-2013_210.backup", "test"}); //ProcessBuilder