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.
Related
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:
I am trying to get a simple guessing game to run when I click the desktop icon. The game prompts the user for inputs in the command window. The program does not have a real user interface aside from one dialogue box. I understand that opening jar files using "javaw.exe" does not open command prompt programs, so I added a dialogue box just to have some indication that it was being opened.
The name of the jar is "guessme.jar"
I have gotten the jar to run properly from the command window by navigating to the proper directory and then issuing the following command :
java -jar guessme.jar
I would expect double clicking the icon would open my dialogue box.
However, when I try to open the jar using a double click, I get the following error:
A JNI error has occurred, please check your installation and try again.
Then I get another dialogue box which says:
A Java Exception has occurred.
I am using JDK 13.0.1.
I made sure that the bin is at the top of the class path. I checked that the system was compiling with the correct version of Java.
Issuing java -version yields 13.0.1.
Issuing javac -version also yields 13.0.1.
I wrote the program in Eclipse. I archived the file using the command prompt.
My package name does not include java or any such keywords. Its just my email.
I have looked around and did not find anyone else who had the same issue. Thank you.
When we click on .jar files which do not contain any GUI the CMD Prompt runs the code and exits it immediately.
How to make it remain open when running a .jar by double clicking on it?
Is there any java code for it? Just like the pause command in batch files or any? I prefer only by java code but not an OS way? and also not by running command java - jar *.jar in cmd prompt.
I'd usually just open a command line first, as suggested in the other answer.
If you need a pure Java code solution though, just read from system in at the end of your code. The window will stay open while waiting for input.
Run the jar file from the command prompt
java -jar yourjarfilename.jar
Something along the lines read a character from std-in along with a print statement telling people to "press any key" should do the trick, provided you have access to the java code that is.
if not well, best option is to drop to CMD and run the command manually.
I downloaded a file for a game that requires Java to run.
When I downloaded the file it saved as a WinRAR file. So I right clicked the file and pressed open with Java Platform SE Binary (As that was the only Java add-on that came up). Then an Error Message came up which says:
Java Installation Not Completed.
Unable to install Java.
There are errors in the following switches:
("C:\Users\MyName\Desktop\The file name for The Game(2).jar").
Check that the commands are valid and try again.
But I have already Installed Java as well.
Has anyone got a fix they could recommend?
One of your files is corrupted. Simply download Jarfix and run it.
The Breakdown has an easy and helpful website to using Jarfix. Simply follow the instructions and download it in the link below:
https://thebreakdown.xyz/jarfix-to-repair-jar-files-on-your-pc/
This can be run by using Command prompt
Open Command prompt (in windows: Windows+R -> type 'cmd' then enter)
Follow the path specified to your specific folder(upto where your jar file exists)
for example: D:\projects\folder1\innerFolder>
now, java -jar filename.jar (then enter)
for example: D:\projects\folder1\innerFolder>java -jar filename.jar
Finally you can see your output
Note: Install java and also set path in environment variables
go try to open it via cmd by following:
press Win + "R" and type in "cmd" and press Enter
Then you type in the following:
java -jar C:\Users\MyName\Desktop\The file name for The Game(2).jar
if that dont work try to give more information (the full error, where do you get the error? As a Messagebox? Or as terminal output?)
It's very simple and easy!
go to your downloads folder
Click on the part where it says downloads and press backspace.
It should show the download icon and an empty bar.
In that area, type: cmd
then press enter
Once command prompt is open, type
java - jar (NAME OF FILE).jar
Example: java -jar Optifine-1.16.5.jar
then press enter. You're done!
Java bin/jar when I double clicked on it first time it opens but again double-clicked on it. it appears the same window like the first one and it open it multiple times how can I stop it. I just want a solution that how can I open a jar like a professional software.
Sorry for my bad english
First check that Java is installed on your machine, by typing "java -version"
If java is installed then you need to goto under that folder where the jar file is present.
Type command "java -jar "
In the above command type your file name in place of