#run JAR file with BAT
1 messages ยท Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
Opening with independent cmd window:
what's the problem ?
here
but it seems to work no ? what is the problem ?
It works when i open a new terminal, and then type "java -jar PATH_TO_FILE.jar", but don't work when i try to put inside a bat file
which error do you get ?
Example:
inside the bat file:
java -jar target/knightstour.jar
PAUSE
Open and closes.
=-=-=-=-=-=-=-=
new terminal window:
"java -jar "C:\Users\User\Desktop\knightstour\knightstour.jar""
Works fine
ok
Works fine... That's weird...
It doesn't work only when I click to run
Apparently, when I click to play, it opens a new terminal on the sys32 folder
and tries to locate the jar inside this folder, but, of course, it fails
but when i specify the path it works fine
no, that's not what i see in the first video
Maybe because you're starting as administrator?
i saw it opening in the correct folder
that was a screenshot from 0:11
I'll see that
I didn't see the video before, Alathreon is correct
๐ค
It does open in the right folder
The system32 is just where CMD lives
at the start of the video
i'm confused ๐
i'll just format my pc
too much logic
Better video ๐ ๐
Nope..
what happens ?
what
please share the jar
I doubt it is the jar tho, it seems like the command immediately fail without showing any error
cause I asked him to
to see if creating a cmd will still cause the same problem
fair. shouldn't be there
start will create another cmd and that one has no pause in it
hence the double window
I could send the github repository, but I think it wouldn't help
that's not the problem tho
opens another terminal then closes
its the cause of that issue. that's what i was replying to. cheers 
it's an observation -_-
the problem is this
yeah but u can't read the error without a pause
and the pause doesn't work
the pause is not applying to the window created by start
this video is better, Zabuzard. This is the problem
please see the previous video
zabu please here โ
when he is running the bat from a terminal, it works
but when he is running by double clicking, it doesn't and immediately close
even without start and with a pause
which shouldn't happen
and uve checked that the jar doesn't run a new Process(...)?
Yep
Nop
It doesn't run a new process. It's a simple unfinished game
Can you share the source
But forget...
Just in case it's something there
well. this is easy to debug locally as u shared the jar file
im on mobile, so I'm out
Probably a private repo, gives me a 404 ๐
Oh yeah
1 sec
๐
clearConsole() was the problem. Problem solved lol
those ansi commands are interpreted differently per console
the first command u had there is supposed to move the cursor at top left and the second is supposed to clear everything from cursor to current print position
resulting in a clear
but seems that cmd just messed it up completely and closes
Still weird that it closed the window though
because cmd is just bad with ansi
unsure. maybe powershell behaves better
Yep.
Didn't think about that..
I'll try to create a new method to do that
afaik cmd has no proper way to clear
cls
public final static void clearConsole()
{
try
{
final String os = System.getProperty("os.name");
if (os.contains("Windows"))
{
Runtime.getRuntime().exec("cls");
}
else
{
Runtime.getRuntime().exec("clear");
}
}
catch (final Exception e)
{
// Handle any exceptions.
}
}
I've seen this in Stack.. But this "exec" method is outdated afaik
Detected code, here are some useful tools:
ur welcome