Running java application from batch file




















Sure, call the java executable. That should be java -jar myjarfile. It's the same way you run it from command line. Just put that "command line" into a ". So, if you use java -cp. If You have jar file then create bat file with: java -jar NameOfJar. Pawel Pawel 8 8 silver badges 25 25 bronze badges. Karan Shah Karan Shah 5 5 silver badges 15 15 bronze badges.

Zaheer M. Asked 6 years, 8 months ago. Active 4 years ago. Viewed 7k times. It would be great if my program would be able to detect this and warn user if the game is running under administrator account: If the user clicks "Elevate", I'd like to ask windows to elevate the java.

Obviously, this time the question would not be about java updater but JRE My question is: Is this possible? I want to avoid restarting the program though it wouldn't probably be such a big deal. I'm not voting to close this as a duplicate, because it's still a good question and with a slightly different wording, but there are a few questions like this: stackoverflow.

There's actually a lot of other questions that toutch the issue and I am still reading another. Thanks for two more! The best you can do is generate a vbs script and run it SergeyTachenov The answers there suggest something I didn't know until now - you can't elevate running process. So I suppose restart will be required. You could make a Launcher that checks for the game's privileges.

And then the Launcher invokes your java application with the same privileges, using ProcessBuilder and the appropriate flags example — gibertoni. Show 5 more comments. Active Oldest Votes. The elevator class: package test; import com.

Native; import com. Kernel32; import com. Kernel32Util; import com. ShellAPI; import com. Full path to the VM may be passed with: -Delevation.

GetLastError ; if lastError! KaBe KaBe 81 1 1 silver badge 1 1 bronze badge. Thanks, that helped a lot. Do not forget to put the classpath inside quotes in case it contains any spaces Add a comment. MouhammedSoueidane How do you know when your frames.

FrameDriver exits? Show 2 more comments. Active Oldest Votes. FrameDriver cmd. Add a comment. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.

Post as a guest Name. Email Required, but never shown. The Overflow Blog. This will not show the command window. Martin Vajsar wrote: Maybe you could show us how do you run the bat file I mean the code you use in updater.

I'd say that you should be able to get rid of the bat file and run java or javaw directly from your updater application. It might help resolve the issue. I also understand that the window of your application is not visible anywhere: taskbar, Alt-Tab list, Task Manager Applications tab just in processes. Is this the case? Also, I assume your main application is a Swing app. It kind of seems that the window of your application exists, but is hidden. Martin Vajsar wrote: Try to replace that code with this: Runtime.

Martin Vajsar wrote: In Windows, there are some convoluted rules concerning application windows after launch, but I believe they govern focus, not visibility. However, if your updater application quits immediately after starting up the main app, it might influence things. Delaying the exit by a few seconds long sleep after that just to see what happens cannot hurt. When you run the application from command line, does it show up nicely? Does it behave the same on all computers? Forum: Java in General.



0コメント

  • 1000 / 1000