How to make VScode debug in a specific terminal? - java

I was using WSL while learning programming in Python at the university, but have Java installed in the Windows filesystem. Now that we switched to learning Java, VScode is trying to debug from the WSL terminal, which does not work. How can I tell VScode to run the debug on the Command Prompt? I guess something path related but I am a bit lost.
I get the following error message:
cmd /C "c:\Users\lukas\.vscode\extensions\vscjava.vscode-java-debug-0.35.0\scripts\launcher.bat "C:\Program Files\Java\jdk-11.0.2\bin\java.exe" -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:50567 -Dfile.encoding=UTF-8 -cp "C:\Users\lukas\AppData\Roaming\Code\User\workspaceStorage\bf1d90699671e44dd71540a7194feefe\redhat.java\jdt_ws\Java DD1380_9c46b501\bin" Sumsort "
Command 'cmd' not found, but there are 17 similar ones.

Open integrated Terminal and click the selection box, choose Select Default Profile, in the popping up list box, choose Command Prompt, then press Ctrl+Shift+` to open a new integrated Terminal, it's cmd.
Debugging .java file is also executed in CMD window in terminal. See the following gif:

Related

Command 'cmd' not found, but there are 16 similar ones

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.

Start Eclipse on MacOS from Java Command line

I'm working with an older version of Eclipse, Helios SR1.
I need to be able to start eclipse from the terminal.
In review of http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F
I execute the following command in Terminal to start eclipse.
/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
and I get
Root exception: java.lang.NoClassDefFoundError:
org/eclipse/swt/SWTError
So this appears to be more complex than what was found in the above link. If I double-click the Eclipse.app it starts right up.
I'm wondering what else needs to be done to allow the Command Line Eclipse Launcher to work properly
You should just be able to use the open command:
open /path/to/eclipse.app
or
open -n /path/to/eclipse.app
will open a new instance of Eclipse even if one is already running.
If you must use the Java command you need to specify -XstartOnFirstThread before the -jar option:
java -XstartOnFirstThread -jar ...
Use the eclipse launcher binary:
<Your-Install-Path>/Eclipse.app/Contents/MacOS/eclipse
Default start-up options are set in eclipse.ini:
<Your-Install-Path>/Eclipse.app/Contents/Eclipse/eclipse.ini
Kepler start-up options are documented here: https://help.eclipse.org/kepler/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html (Helios link redirects to Kepler, the oldest one they have kept available)
The launching process is explained in detail here: https://help.eclipse.org/2019-03/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/launcher.html

Opening Java programs in command prompt through SublimeText3

Similar to TextPad, I want SublimeText3 to open up the command prompt after it compiles the java file. I don't want to run the programs in SublimeText3. I have jdk1.8 and have set up my PATH variable already. It becomes annoying to have to keep typing java and javac.
Press shortcut key(s) -> Sublime compiles and opens command prompt with the program running.
Any help would be appreciated.
What you need to do is set up a build system so that Sublime knows how to compile and run your program. You can find more info on that here if you don't know how to do that already.

Run NetBeans java project by windows command prompt

I wrote a java program by netbeans 6.9.1 and jdk 1.6. I don't want to use the output windows of netbeans because it's a bit slow. I am using Windows xp sp3 and I want to run by the cmd. I tried to find in the project properties -> run but nothing there.
If you run the project in netbeans it should ask you to pick the main class. In your case that is already done because there is a value of sample.Graph in the Main Class field.
Then do a clean and build and look at the output window. It should tell you what java -jar command to use to run the program on the command line.

Run Java file Service Mac

So far i've created a service using automator to compile a Java file. This means that i can compile a java file through its contextual menu.
Unfortunately I cannot do the same with running the Java file. Through automator I can get it to run the java file perfectly, showing the results in the automator window, however it will not open the Terminal window to view the java file. I did this using this code:
java -classpath `dirname "$1"` `basename "$1" | sed "s/.class//g"`
Applescript on the other hand can run Terminal commands into a Terminal window for all to see using code such as:
on run {input, parameters}
tell application "Terminal"
activate
do script with command "java -classpath" & input & input
end tell
end run
The correct way to run a java file is:
java -classpath /path/to/ file
Can anybody please help?
Thanks in advance.
Utilities > Run Shell Script with Passing input: as arguments seems to work in this context.
Addendum: If you want to open Terminal, something like this may work.
open -a Terminal ~/your/script.sh

Categories

Resources