1

Have you had experience with running a jar file using a command line, wrapped in a Windows service?

I'm trying to find a way to run a jar file without being logged into the machine, and since it allows command shell, I was wondering if it's a good idea.

Thanks!


Original Post:

I'm trying to run Associated Press's Web Feeds Manager, which is basically a jar file that can be run when logged in by double clicking it.

I'd like to run the same file but without being logged in to the machine. In their manual (http://wfm.ap.org/admin/content/help/Running_Agent_on_a_Remote_Server.htm) they write how to do that, using a commandline parameter.

Basically I'd like the jar to run as a Windows service, regardless of who's logged in, but Googling it showed it was problematic.

Have you had experience with remotely running jar files? What are the pitfalls?

Thanks!

Nir
  • 3,635
  • 7
  • 33
  • 49

5 Answers5

2

On a google search, I came across this article -

Running Jar Applications as a Windows Service

It mentions about open source Java Service Wrapper project from Tanukisoftware.org for accomplishing this task.

Note: I've not used this personally.

Swapnil
  • 7,762
  • 4
  • 34
  • 56
0

If you are not interested in having the service started/stopped at boot/shutdown, but you just want the program to be started manually and keep running after logout, here is what you do:

$ nohup java -jar foobar.jar > foobar.log 2>&1 &

which means: start my foobar.jar (java -jar) and keep it running after I logout (nohup) redirect stdout to foobar.log (>) and also the stderr (2>&1), and make it running in background (& at the end).

Instead, if you are interested in installing a "service" in your linux box, there are many options, depending on what distribution you are using. The most common are upstart (for ubuntu) and System V init scripts (Redhat or others). Also cron can be used to start/stop services at startup/shutdown. You can find an example of installing a java app (hudson) on an init system here, or doing the same thing with upstart. Or, as I said, cron could be an option.

On Windows, there is Java Service Wrapper. And not much more.

Community
  • 1
  • 1
Luigi R. Viggiano
  • 8,103
  • 6
  • 46
  • 60
0

For windows Java Service Wrapper is a better choice

Nidhish Krishnan
  • 19,751
  • 6
  • 56
  • 72
0

My favourite is the upstart on linux, but it is Ubuntu only.

On Windows I see many alternatives according to this forum.

Community
  • 1
  • 1
BTakacs
  • 1,897
  • 3
  • 20
  • 25
-1

Tool Exe4j

You can use Exe4j.exe, that tool generate service.exe file from .jar file

You can download Exe4j from here: Download exe4j

Bill the Lizard
  • 369,957
  • 201
  • 546
  • 842