When I run:
new ProcessBuilder("kotlinc", "-help").start();
I get the error: Cannot run program "kotlinc": CreateProcess error=2, The system cannot find the file specified
I've tried:
If I check my path from windows, it contains C:\Apps\kotlinc\bin, and when I open explorer at that location, there's a file named kotlinc.
If I open cmd.exe anywhere, and run kotlinc, it works just fine.
If I print out my environment:
System.out.print(new ProcessBuilder("kotlinc", "-help").environment().get("Path"));
it contains C:\Apps\kotlinc\bin
If I run new ProcessBuilder("python3", "file.py").start(), it works just fine.
Rebooting my machine
Changing kotlinc to use the full file path is not an acceptable solution, as this is being run across multiple computers and platforms.
As far as I can tell, everything is setup correctly.
Why can't I run kotlinc from ProcessBuilder?
kotlinc is actually a batch file (kotlinc.bat), not a binary file. Therefore, you need to start it by executing the command cmd /c kotlinc.
Related
I'm trying to execute a Java file I was given on Windows 10, inside of the Bash shell.
I open my command prompt. I enter bash.
I set
JAVA_CALL="C:/Program Files/Java/jdk1.8.0_192/jre/bin/java"
I try to execute the call, but to no luck. I read several threads on here and tried several things. I made sure my path includes both the Program Files x86 and the regular Program Files version of my JAVA.
I executed
sudo ln -s -f /mnt/c/Program\ Files/Java/jre1.8.0_192/jre/bin/java.exe /bin/java
To try and make a link to it. I cannot get it to wrong. It always tells me
-bash: C:/Program Files/Java/jdk1.8.0_192/jre/bin/java: No such file or directory
I am sure that file exists. Any ideas?
I am trying to run a java program on a text file got from this github page-
https://github.com/dbamman/book-nlp
This is the command it asks me to run -
./runjava novels/BookNLP -doc data/originalTexts/dickens.oliver.pg730.txt -printHTML -p data/output/dickens -tok data/tokens/dickens.oliver.tokens -f
I have followed the other instructions and run the file from the book-nlp-master folder (I have downloaded the zip file)
This command worked on Linux as far as I remember, but on Windows cmd it gives me this error-
'.' is not recognized as an internal or external command,
operable program or batch file.
If i switch the slashes as they are given in windows, it gives me -
'.\runjava' is not recognized as an internal or external command,
operable program or batch file.
How do I fix this. I ran this on Linux and it worked for me, but I don't remember what I did.
P.S. running 'runjava' gave the same error.
If you want to use Bash script with Windows, I suggest you use Git Bash. Git Bash is provided with Git installation for Windows.
Git : https://git-scm.com/downloads
You use Cygwin or Powershell which comes with the Github for Windows.
ImageMagick commands are not working from JAVA code.
Runtime.getRuntime().exec("compare /Users/labuser/Downloads/test.jpg /Users/labuser/Downloads/test1.jpg /Users/labuser/Downloads/differnce.jpg");
Exception:
java.io.IOException: Cannot run program "compare": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
When i tried from Terminal it works fine and produced output file in specified path.
I have verified for echo $PATH and it set to be
PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/ImageMagick/bin
Anyone please suggest me for should i need to add something to work these command from Terminal?
For other commands it working fine from terminal and error only with imageMagick commands
Thanks # trashgod
Its working while specifying the full path to ImageBrick API's like
Runtime.getRuntime().exec("/opt/ImageMagick/bin/compare /Users/labuser/Downloads/test.jpg /Users/labuser/Downloads/test1.jpg /Users/labuser/Downloads/diff.jpg");
I have a jar file named test.jar, which I am running with a batch script from the same folder.
Here's the batch code:
java -jar test.jar
pause
The jar itself works with no problems, and I can run it just fine.
However, if I try to run the batch file as an administrator (by right clicking it and choosing "Run as Administrator"), I get the following error:
Error: Unable to access jarfile test.jar
I'm using Windows 8.1, but this also happened on a machine running Windows 7.
What can I do to be able to run this as an Administrator?
i had the same problem that you and i solved it by changing
java -jar test.jar
to
java -jar %~dp0test.jar
%~dp0 holds the directory of your bat file (AFAIK) so %~dp0 will give Java the full path to the jar file solving the problem.
You could also ad a temp path to java
path=C:\Program Files\Java\jre1.8.0_40\bin
Java script
path=
I am trying to make a eclipse project in Java to launch commands with some buttons. The libraries of Ros fuerte (These ones i want to use) are correctly installed and concretly i am trying to launch a ros command from a Java File using:
String cmd = "roscore";
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(cmd);
If i launch this command from a current terminal it works, but if i do it from the java file i have a problem because the terminal doesnt recognize the command.
java.io.IOException: Cannot run program "roscore": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at java.lang.Runtime.exec(Runtime.java:610)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at LaunchTerminal.main(LaunchTerminal.java:24)
I think that i need to add some path or similar but i dont find the information. Does anybody know how to do it?
Thank u.
only normal commands are possible to execute like rm or cd ... al others must be referenced with full path of context
Do the following if you are using the groovy distribution:
String cmd = "source /opt/ros/groovy/setup.bash && roscore";