So, I am not new to Java and compiling in cmd but I am pretty new to using windows powershell. I have 'javac' and 'java' commands running fine in CMD and all java programs compile using netbeans and eclipse. I can also use javac inside windows powershell with no problems, but when attempting to run a java program, i.e. java MyProgram, after compiling it I get the following error...
Error: could not open 'C:\Program Files (x86)\Java\jre7\lib\jvm.cfg
Now I am running Java 8, so I have no idea why it would be looking for a file like this since CMD confirms that both 'java' and 'javac' are running version 8 and have the correct path set, or they would not run there. And please do not just tell me more about setting the paths because I have checked and checked and checked again. Also, I have made sure that anything that is related to java version 7 that I could find has been uninstalled / deleted.
Well, any advice would be appreciated. Thanks a bunch.
Try to start you application using a small cmd oder bat-File. Powershell does a lot of parsing and destroys your call. I usualy use something like this:
$Result = Invoke-Expression "cmd /c $Tempbat"
One alternative is to use the stop-parsing character: --%
icacls c:\scripts --% /grant ***\ScriptAdmin:(CI)(OI)F
Related
I'm trying to run a java program on windows in VSCODE. When I click the run button at the top it opens the Java Process Console and runs the following command:
$ cmd /C "c:\Users\user\.vscode\extensions\vscjava.vscode-java-debug-0.31.0\scripts\launcher.bat "C:\Program Files\AdoptOpenJDK\jdk-11.0.10.9-hotspot\bin\java.exe" -Dfile.encoding=UTF-8 #C:\Users\jbree\AppData\Local\Temp\cp_7gau2431e54dxprosf092viw9.argfile com.example.restservice.RestServiceApplication "
It then prints out: Command 'cmd' not found, but there are 16 similar ones., and I'm not too sure what to do afterwards.
I just ran into this exact issue! After some debugging, I found out it's because my terminal (in VS Code) was running off of WSL.
Make sure to check which terminal you're using! If you're trying to run Java locally, then you can configure a default shell ie. bash.
Let me know if this helps.
Edit: I also found this, not sure if it will help, but here you go!
https://stackoverflow.com/a/58058378/11060097
your java debugger is using wsl. and most likely your java is installed on windows. not linux on windows. to fix this for me, i changed the settings for java debugging to use the external console. settings->java debugger->externalTerminal . this will then use the "external windows" setting for vscode. which should use cmd.exe (the windows shell, no linux).
This error happens because you probably have wsl has your standard terminal but it's probably configured to launch cmd using a windows path.
WSL won't understand what that windows path is, so you need to change it using a path structure it can understand
So
hit Ctrl+, to hit the Settings screen
type in terminal to see all the terminal settings
You will see an option called Terminal> External:Windows Exec
Change C:\Windows\System32\cmd.exe to /mnt/c/Windows/System32/cmd.exe
I had this error too and came here initially but I managed to figure out it was an incompatible path issue that was the cause.
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 compile java files using either the command prompt or Git-Bash (running Windows 7) but I am having no luck. I've researched this and followed the simple steps of checking the version of Java I have by running:
java -version
from the command line and I get "1.8.0_102".
So I went to my PATH variable and appended:
;C:\Program Files\Java\jdk1.8.0_102\bin
I have checked what seems like a thousand times and this is the proper directory, but when I run
javac
from the command line, I still get the error
'javac' is not recognized as an internal or external command, operable program or batch file.
Can anyone huide me in the right direction?
Try to set
JAVA_HOME system variable to C:\Progam Files\Java\jdk1.8.0_102;
and add %JAVA_HOME%\bin; to your CLASSPATH variable
Then restart the command line and try
It's official, dumbest mistake I've made yet. I wrote
Progam Files
not
Program Files
I would like to be able to run a sencha compilation without a full java installation on my machine. I.e. I want to just include the java binaries in a tools folder. The only part of the compilation that doesn't work currently is the final part which compresses the js files. I'm getting the following error:
uncaught exception: Stream:"Could not open the pipe" (exec://java -jar
"C:\projects\Tools\SenchaSDKTools-1.2.3\jsbuilder\ycompressor\ycompressor.jar"
--type js -o "C:\inetpub\wwwroot\ext\WebApp\app-all.js" "C:\inetpub\wwwroot\ext\WebApp\app-all.jstemp-1098294810303.0708")
To try this out I created a simple js file which does only the failing step:
var cmd = 'java -jar "C:\\projects\\tools\\SenchaSDKTools-1.2.3\\jsbuilder\\ycompressor\\ycompressor.jar" --type js -o "C:\\inetpub\\wwwroot\\ext\\WebApp\\app-all.js" "C:\\inetpub\\wwwroot\\ext\\WebApp\\app-all.js-temp-1098294810303.0708"';
var stream = new Stream('exec://' + cmd);
stream.close();
then ran the simple js file using jsdb from a command line:
jsdb simple.js
When java is fully installed the above code works fine, when I uninstall java the above line fails with the error message above.
I'm guessing it's something todo with the java alias. I have little to no knowledge of this framework/language, so I'm hoping it's going to be very obvious to some experts out there as to how to fix this without a full java install. I.e. making the java alias know the location of the java binaries.
Oh dear... thanks to Jacob for helping me on this..
Add the java locations to the path environment variables and it work.
E.g.
C:\JavaLocation\jre6;C:\JavaLocation\jre6\bin
I'm trying to wrap a program of mine to work with java.
I tried a simple "hello world" first,
-hello world.m-
disp('hello world');
I used deploytool and selected java package.
when it reached this line:
Executing command: "javac -verbose -classpath "C:\Program Files\MATLAB\R2009b\toolbox\javabuilder\jar\javabuilder.jar" -d "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\classes" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\helloworld.java" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\DeployTutorial2MCRFactory.java" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\helloworldRemote.java" "C:\Users\shachar\Documents\MATLAB\deployTutorial\deployTutorial2\src\deployTutorial2\package-info.java""
I got this error:
'javac' is not recognized as an internal or external command,
operable program or batch file.
Error: An error occurred while shelling out to javac (error code = 1).
Unable to build executable.
btw: when I tried standalone application / c/c++ shared library it has been compiled successfully.
thanks in advance
Possibly the Java SDK is not installed or properly configured on your machine. Open a system terminal and execute the following two commands:
java -version
javac -version
If they both work you should proceed with the examples from the MATLAB help. If not install the Java SDK.
First you should install JAVA.
Then you must set the environment variable in "my computer"
Add a new variable named "JAVA_HOME" and set its value to your jdk path
like D:\Program\Java\jdk1.6.0_25
Then restart your matlab
and type
getenv JAVA_HOME
you should get
ans=
D:\Program\Java\jdk1.6.0_25