[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

java.exe launched by SYSTEM/Windows Service got killed after user logoff

Posted on 2012-09-19
8
Medium Priority
?
984 Views
Last Modified: 2012-09-22
Hi there,

I want to run a java application at machine reboot and without interruption afterward.
A Windows service is written to start the java class.  java class runs fine at reboot
without any user login.  I can check from another machine over network.  After user
(without admin privilege) login, Windows Task Manager shows the service and java.exe
under user name SYSTEM from Processes tab.  At this point, the java class is still
up and running.  

However, the java class got killed after the user without admin privilege logs off.
I can check from another machine through network if the java application is
running or not.  Login again only see the Windows service (under user name SYSTEM)
launching the java class from Windows Task Manager.  But java.exe (initially also
under user name SYSTEM) is gone.

How to let the java class continue to run without interruption?   The OS is
XP Pro SP3.  Java JRE version is 1.6.0_16.

Your opinion is very much appreciated.
0
Comment
Question by:asugri
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 38416700
How does the service start/run the java class ? Can I see it pls
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38418046
Sounds wrongly configured.  You should probably just use a service wrapper, e.g. http://wrapper.tanukisoftware.com/doc/english/download.jsp
0
 
LVL 16

Accepted Solution

by:
imladris earned 2000 total points
ID: 38422402
Using a standard wrapper such as the one from tanukisoftware is certainly a good option.

However, I have not used it for various reasons. One of the things to deal with is the one you mentioned; a Java process will normally be killed when the user logs off.

This can be avoided, depending on the JVM you are using, with a commandline option. In the JVM I am using, from Sun I believe, there is a -X (non-standard) option to reduce the JVM's use of OS signals. So I start the JVM with -Xrs, and now it does not get killed when the user logs off.

Since this is a non-standard option it may not have the same syntax for other JVM's, or may not be available at all.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Expert Comment

by:CEHJ
ID: 38422615
However, I have not used it for various reasons. One of the things to deal with is the one you mentioned; a Java process will normally be killed when the user logs off.
That should not be the case:
http://wrapper.tanukisoftware.com/doc/english/faq.html#6
0
 
LVL 16

Expert Comment

by:imladris
ID: 38423857
Correct; if you're using the tanuki (or probably other) wrappers, there is no logoff problem.

The questioner, however, was not using a wrapper, and neither am I. In that case, the solution is along the lines I indicated.
0
 

Author Comment

by:asugri
ID: 38423943
Thanks for all the tips.   I used java -Xrs to run the class and it stayed running with user logoff.
0
 

Author Comment

by:asugri
ID: 38423945
According to
http://superuser.com/questions/374147/java-services-stop-working-when-user-logs-out

You need to add the -Xrs flag to your java.exe command line to prevent the JVM from exiting when you log off an XP machine. The problem doesn't arise on Windows 7 (or Vista/Server 2008) because "Session 0 Isolation" prevents users from logging in (and thus logging off) Session 0, the place where services are run.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38424337
That will work but should probably be regarded as a kludge. It sounds like you have what is essentially a service, albeit written in Java. If so, it should probably be made as far as possible to behave as a proper service. That means one that responds in a proper way to signals from the OS and is not forced to remain running by ignoring them. For one thing, a robust solution would log such events normally and be portable to other environments without fear of breakage.

Of course, it's difficult to say exactly how far it misses an optimal solution without knowing the details (i.e. the source code) of the implementation of the -Xrs flag. I suspect it might be a case of that not being available, another instance of Java being somewhat less than 'open source'. I'd be happy to be told otherwise, if any of you know.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month20 days, 9 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question