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");
Related
I was able to compile and run my java code from CMD, however when I try to run the same commands in PS, I am getting error messages. I have read and been told that CMD commands will work in PS, but the CMD commands are not working in PS
Here is the line that I am using to execute my program:
java -classpath .;stanford-corenlp-3.8.0.jar;stanford-corenlp-3.8.0-
javadoc.jar;stanford-corenlp-3.8.0-models.jar;stanford-corenlp-3.8.0-
models.jar Test.TestCoreNLP
I am running the command from the directory where my needed JAR files are located. The error message says...
The command stanford-corenlp-3.8.0-models.jar was not found, but does exist
in the current location. Windows PowerShell does not load commands from the
current If you trust this command, instead type: ".\stanford-corenlp-3.8.0-
models.jar".
Made the change and the code looks like this now.
java -classpath .\;stanford-corenlp-3.8.0.jar;stanford-corenlp-3.8.0-
javadoc.jar;stanford-corenlp-3.8.0-models.jar;stanford-corenlp-3.8.0-
models.jar Test.TestCoreNLP
Still getting the exact same error message. I have also tried going up a directory and no luck. I have looked all over StackOverflow and I have done my research.
Any help would be much appreciated.
Thanks.
Using .\ would work for one file, but since you have a number of files, you should reference the current directory in each one of those files.
java -classpath .\stanford-corenlp-3.8.0.jar;.\stanford-corenlp-3.8.0-javadoc.jar;.\stanford-corenlp-3.8.0-models.jar;.\stanford-corenlp-3.8.0-models.jar .\Test.TestCoreNLP
Java 6 also supports wildcards, as this answer indicates, so you might try simply this.
java -cp ".\*" .\Test.TestCoreNLP
I came here with similar trouble, and what I found is that when running like this:
java -cp .\target\somelib.jar;.\target\myapp-1.0-SNAPSHOT.jar com.ethoca.app.myapp
I would get help info. My discovery is that I need to double-quote my list of classpath, like:
java -cp ".\target\somelib.jar;.\target\myapp-1.0-SNAPSHOT.jar" com.ethoca.app.myapp
I have a Java jar of which I would like to turn into a .exe file for Windows. Only problem is that I get the following error when building it through Launch4j on Linux net.sf.launch4j.ExecException: java.io.IOException: Cannot run program "/Desktop/launch4j/bin/windres": error=2, No such file or directory. I am not completely sure what is wrong, as I have tried to use the same Launch4j setup along with the same jar with Launch4j but on a Mac instead, which worked perfectly.
I have tried to search for the error on Google, but I wasn't able to get any results and on the Source-forge page with the actual download link, there are no one who have mentioned this error, at least it seems.
To me it appears as if there is something missing in the Launch4j folder? When launching the Launch4j jar to use the program, I am using the following command in the Linux terminal Java -jar launch4j and the program does open, the error first appears when trying to build the executable.
I had the same problem with launch4j on MACOS while using the launch4j ant task. I could solve the problem by copying (not moving) the macos executable located in the launch4j/bin to a newly created sub director launch4j/bin/mac. So I have got:
-launch4j/bin
ld
windres
-mac
ld
windres
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.
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.
Im trying to run a jar file from php using shell_exec(java -jar C:/myfile.jar).
Its not working and Im getting the following error in the apache error log.
"java is not recognized as an internal
or external command".
Its working from the windows command prompt very well.
Please help.
It sounds like the java.exe executable isn't on the path.
Just include the fully-qualified path to it, with quoting where necessary if the directory contains spaces.
You can try this
exec("java -jar WaveAppender.jar ")