• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run my java program in the background  RSS feed

 
Stan Weigh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I'm currently writing a java program that is going to act as a small server, listening to a port...
Previously all I have made in java are GUI apps, so the problem is this: How can i make my program run in the background, without having it on my task bar?

EDIT: I'm jusing NetBeans btw, if that matters

EDIT2: and Windows.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you start your program with javaw instead if java, it will be opened without a console window. If the application doesn't open any windows itself, then it shouldn't appear on the taskbar. If you package it in an executable JAR then you could just double-click on the icon to start it.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware: if you use the java.io.Console class and run a program in the background, any Console objects will be null.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can use a Java Service Wrapper, which can run as a windows service.
 
Stan Weigh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, all, for replys. Problem solved
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done Tell us how you did it.
 
Stan Weigh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I noticed "my problem" wasn't really my problem. I had set up the app to run in background properly, but it seemed I messed up my socket, so it crashed before it could do anything :p
To make it run in background I just made it like a GUI app, just without creating the GUI. Much easier than i thought: Made a new class and compiled it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!