Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I easily make a java application invisible to the user?

Tags:

java

I have developed a Java aplication that is currently being run by double-clicking on a ".bat" file that does something like "java -jar proy.jar". This application just listens on a port and writes to a database, so it does not have any user interface (such as a window). I need this application to run as in background mode, or as it were a service, but I don't really anything more than that. It's enough if the application is run in a way that is not noticeable by the user, so that the user is not bothered and so the application can not be mistakenly closed. By the way, this will be run on an specific computer so it's okay if I have to do any manual configuration ir order to make this work. Also, I need this application to run on startup.

Any help/tips regarding this? In advance, thank you very much for your help!

Regards,

Pedro

like image 292
Pedro Bellora Avatar asked Jun 16 '10 02:06

Pedro Bellora


People also ask

Which method is used to show the frame window?

Java AWT Programming Project We can implement most of the java swing applications using JFrame. By default, a JFrame can be displayed at the top-left position of a screen. We can display the center position of JFrame using the setLocationRelativeTo() method of Window class.


1 Answers

use javaw.exe instead of java.exe and you will not get a console window.

from the java.sun.com:

The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.

EDIT:

A .bat will start a console. If you can live with a console up for a fraction of a second, you can preface your call to javaw with start. This will spawn another console-less process for javaw and allow the console-ful bat to exit.

like image 136
akf Avatar answered Nov 15 '22 17:11

akf