Consider the following script:
println "ls -l".execute().text
Why do I get the following error when running with JDK 1.6.0_14?
Caught: java.io.IOException: Cannot run program "ls": java.io.IOException: error=40, Too many levels of symbolic links
at a.run(a.groovy:2)
When run with JDK 1.5.0_08 I get the expected output. This, by the way, is one of the examples on the Groovy Process management page. A simple solution seems to be to run it within a shell:
println ["/bin/sh", "-c", "ls -l"].execute.text
But this shouldn't be necessary, no?
Have you tried this?
println "/bin/ls -l".execute().text
Related
I can run kubectl get secret/rabbitmq-expressmode -n expressmode in shell successfully.
However when I try to run it in java with either ProcessBuilder or Runtime.getRuntime().exec, the error:
Error from server (BadRequest): the server rejected our request for an unknown reason
is thrown out.
What's the possible reason?
Best approach would be to use official java client library.
Installation is pretty easy, and code examples shows you how to use it.
If the official one does not meet your requirements, there are also community-maintained client libraries:
Java (OSGi)
Java (Fabric8, OSGi)
Java
I had same issue but resolved by programmatically creating bash file containing kubectl... command I was trying to execute directly.
For example, create bash file and put your kubectl command there (i.e.: some-file.sh). Then try then executing it in bash process running within your java code (bash some-file.sh).
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 am trying to run a Java command in python like this:
import subprocess
subprocess.Popen(['java -Xmx1024m -jar /maui-standalone-1.1-SNAPSHOT.jar run /data/models/term_assignment_model -v /data/vocabulary/nyt_descriptors.rdf.gz -f skos'], cwd=r'/Users/username/Repositories/RAKE-tutorial/', shell=True)
Unfortunately it is throwing an Unable to access jarfile /maui-standalone-1.1-SNAPSHOT.jar error. I have checked the permissions and tried a number of other options including using the os.system command to run a shell script. The error still remains. There seem to be a lot of people who have encountered the same problem but none of their solutions seem to work for me. Any suggestions? Let me know if you need any more information. Thanks in advance!
use fullpath to file
like
command = f"java -jar {os.path.dirname(__file__)}\\jar_name.jar"
process = subprocess.run(
command,
shell=True,
universal_newlines=True,
capture_output=True,
text=True,
)
it help's me
I'm trying to run testng via command line and I used following command:
Actually my os is linux ubuntu and i used command:
java -cp "lib/*:bin" org.testng.TestNG testng.xml
It is pretty clear what the problem is. The class that the error message is complaining about is not on your classpath ... just like it says.
Either you have got your classpath incorrect (e.g. what comes after the -cp) or you have got the name of the class incorrect. (I expect that needs to be a fully quaklified classname ... and maybe you've given something different.)
On possibility is that the shell is "globbing" the * in the classpath. Try running echo "lib/*:bin". If it doesn't echo lib/*:bin then you need to escape the * to stop the shell expanding it. However, the double-quotes ought to suppress globbing, so I doubt that this is the problem.
So from reading the documentation, the way I'm attempting to invoke rspec is:
java -jar jruby-complete-1.6.7.jar -S spec -b -f d rspec_sanity_check.rb
I've also tried rspec instead of spec. In each case, I get the error:
jruby: No such file or directory -- spec (LoadError)
I'm not sure what to do here. Although the documentation says jruby-complete has rspec, I can't seem to run it.
I'm attempting to use jruby-complete to bootstrap our java based buildsystem so I don't have to install gems on each new vm.
Any thoughts on how to get jruby-complete rspec to work?
seems to work just fine with 1.6.7 :
$ java -jar org.jruby/jruby-complete.jar -S rspec
Run filtered using {:full_description=>/(?-mix:Handler)/}
No examples were matched. Perhaps {:if=>#<Proc:0x8d00c6#/opt/local/rvm/gems/ree-1.8.7-2011.12/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:50>, :unless=>#<Proc:0x12dcb8c#/opt/local/rvm/gems/ree-1.8.7-2011.12/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:51>} is excluding everything?
Finished in 0.002 seconds
0 examples, 0 failures