XMLBeans: java.io.IOException: Cannot run program "C:\xmlbeans\bin\jar": - java

I'm trying to run XMLBeans:
scomp -compiler "C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe" -cp "C:\Components\*";"C:\Components\jsr173_api.jar";"C:\xmlbeans\lib\xbean.jar";"C:\xmlbeans\lib\xbean_xpath.jar";"C:\xmlbeans\lib\jaxen-1.1-beta-2.jar;" -out S2002PDPIn.jar S2002PDPIn.xsd
It gets an error below:
java.io.IOException: Cannot run program "C:\xmlbeans\bin\jar":
CreateProcess error=2,
The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at org.apache.xmlbeans.impl.tool.CodeGenUtil.externalJar(CodeGenUtil.java:304)
at org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.java:841)
at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:272)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
BUILD FAILED
At first I thought the "C:\xmlbeans\bin\jar" it was looking for was a directory so I just created a folder "jar", but when I run it again the "jar" was referred as a file where I get error:
java.io.IOException: Cannot run program "C:\xmlbeans\bin\jar":
CreateProcess error=5, Access is denied
Please kindly help me how to fix this so that it don't look for "jar" file.
I looked "scomp.cmd" but there is no line that will do this.
Thank you in advance.

You are simply calling more applications, than you expect:
scomp -compiler "C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe" -cp "C:\Components\*";
"C:\Components\jsr173_api.jar";
"C:\xmlbeans\lib\xbean.jar";
"C:\xmlbeans\lib\xbean_xpath.jar";
"C:\xmlbeans\lib\jaxen-1.1-beta-2.jar;" -out S2002PDPIn.jar S2002PDPIn.xsd
This happens because of ";", you would have to enclose the complete classpath with one " and seperate the values by ;.

Related

issue with running git commands from java program

I am trying to run a git command through java program using
Runtime.getRuntime().exec(commandToBeExecuted);
and commandToBeExecuted ="git log" ;
i have set env variables but still getting the error like:
java.io.IOException: Cannot run program "git": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at GITCodeCoverage.createLog(GITCodeCoverage.java:40)
at GITCodeCoverage.main(GITCodeCoverage.java:17)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:188)
at java.lang.ProcessImpl.start(ProcessImpl.java:132)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 5 more
Any can please help me in this run this command succesfully on Windows system.
Thanks in advance!
Try using this overloaded Runtime.exec(String command, String[] envp, File dir) like:-
File gitPath = new File("path where git is located in your system");
Runtime.exec('git logs', null, gitPath);

Java error in making file through console

I want to make a file though the cmd in java using this code
Runtime.getRuntime().exec("mkdir C:\\Users\\Nick\\test");
and i get this annoying error:
Exception in thread "main" java.io.IOException: Cannot run program "mkdir": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at LFID.main(LFID.java:11)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
I have no idea what's causing it so help.
By the way please don't tell me how to create a folder not through cmd, I need to do it this way. Thanks.
mkdir isn't a standalone executable you can launch as a separate process - it's a command that the Windows command shell understands.
So you could run cmd.exe /c mkdir ...:
Runtime.getRuntime().exec("cmd.exe /c mkdir c:\\Users\\Nick\\test");
Or:
Runtime.getRuntime().exec(
new String[] { "cmd.exe", "/c" "mkdir" "c:\\Users\\Nick\\test"});
... but I'd still recommend just using File.mkdir instead... why call out to an external process when you can do it within Java? (If you're going to specify an odd requirement, it helps to give some more context on it...)

Execute Shell Script using Http path in java program

i have a path where i have shell script which i have to execute using java program but i am getting error as .
Runtime.java
public class Runtime {
public static void main(String[] args) {
System.out.println("Triggered");
try {
Process p = Runtime.getRuntime().exec("\"http://192.168.1.7/sh_scripts/check_process/2.sh\"");
System.out.println(p);
} catch (IOException e) {
e.printStackTrace();
}
}
}
LOGCAT
http://192.168.1.7/sh_scripts/check_process/2.sh: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at com.howtodoinjava.demo.poi.Runtiime.main(Runtiime.java:15)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
Did i miss anything while executing . The path is not geeting read from the java program to execute the shell script So please help me to execute the jar file using the given http link where i can execute the 2.sh file successfully using java
As far as I know, you can only execute an executable FILE on the same computer, there is no support for downloading a script from a remote server in http, ftp or whatever else.
Same is true also in a normal unix shell.
So, you have a few options :
Download the .sh file yourself in java, put it in a temporary file, and execute it there
Run another .sh file that downloads the .sh file from http and executes it; can be a oneliner, like source <(curl -s http://192.168.1.7/sh_scripts/check_process/2.sh)
Try to execute this oneliner, maybe using ProcessBuilder can ease the creation of the redirection etc.. but I'm not sure.

Word Topology deployment error

I am getting the following error when I try to deploy the Word Topology in windows.
I have followed the below link to deploy the word Topology in windows.
http://ptgoetz.github.io/blog/2013/12/18/running-apache-storm-on-windows/
When i deploy and see I am getting the floowing error.
java.lang.RuntimeException: Error when launching multilang subprocess
at backtype.storm.task.ShellBolt.prepare(ShellBolt.java:105)
at backtype.storm.daemon.executor$fn__3493$fn__3505.invoke(executor.clj:689)
at backtype.storm.util$async_loop$fn__457.invoke(util.clj:431)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Cannot run program "python" (in directory "storm- local\supervisor\stormdist\WordCount-1-1407303402\resources"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at backtype.storm.utils.ShellProcess.launch(ShellProcess.java:50)
at backtype.storm.task.ShellBolt.prepare(ShellBolt.java:102)
... 4 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:189)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
Can anyone help me.
I had the same error.
Look at the compiled source. In the target folder you need all the scripts of the mutlilang available to execute all of them.
Look at target/classes/resources/ if there are any files. If not and if even you do not have the folder in target/classes copy the the resource folder from multilang/resources into the target path.

executing Runtime.getRuntime.exec(String cmd)

Hi
I am trying to execute the command string with Runtime.getRuntime.exec(String cmd).What
i'm actually trying to extract the I frames from video using the MPlayer and it is
installed in the different directory than that of my eclipse workspace.
I'm using the java code like the below
C:\\\Program Files\\\MPlayer for Windows mplayer file.mp4 -benchmark -noframedrop -ao null -vo jpeg:outdir=iframes -vf framestep=I
the actual command to extract using DOS is
"mplayer file.mp4 -benchmark -noframedrop -ao null -vo jpeg:outdir=iframes -vf framestep=I".
The ECLIPSE WORKSPACE is in my d: drive.And the Mplayer is in c:\program files\Mplayer for windows.
Eclipse IDE shows the exception as:-
Exception in thread "main" java.io.IOException: Cannot run program "C:\Program Files\MPlayer for Windows": CreateProcess error=5, Access is denied
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at myvideo1.main(myvideo1.java:39)
Any help is greatly appreciated.
Try this:
exec("\"C:\\Program Files\\MPlayer for Windows\\mplayer\" file.mp4 -benchmark -noframedrop -ao null -vo jpeg:outdir=iframes -vf framestep=I");
I surrounded the command in \" since the path contains spaces and added a missing \ in front of mplayer.

Categories

Resources