Skip to content
Advertisement

I was able to compile my java code from PowerShell, but cannot run it

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.

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement