Solved

Running Java class as Win NT service

Posted on 1997-06-03
8
335 Views
Last Modified: 2012-05-07
I'm trying to run a java class TestService from MS SDK 1.5 as a Win NT service. When I'm attempting to start it, i get the following error:

Could not start <servicename> service on <server>
Error 2140: An internal Windows NT error occurred.

and in Error log file there appears:
Service class "TestService.class" could not be created: java.lang.ClassNotFoundException: TestService/class

In my opinion, there's a problem with the strange conversion from TestService.class into TestService/class -> I'm not able to force point in place of slash in TestService/class.

Roman Dusek
0
Comment
Question by:dusek
8 Comments
 
LVL 1

Expert Comment

by:mlimotte
ID: 1221181
What is the command line that your are using to start the class?  
0
 

Author Comment

by:dusek
ID: 1221182
The command line follows:
svcsetup.exe TEST_Srv c:/java/TestService.class -classpath c:\java\service.zip;c:\system\winnt\java\classes -displayname TEST
0
 
LVL 1

Expert Comment

by:mlimotte
ID: 1221183
I've never tried doing this, so I may be way off, but I don't see any mention of the Java VM (java.exe) in the command line.  How will NT know how to interpret you class file.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:dusek
ID: 1221184
There's a dll (JavaService.dll) that is to copy to %PATH% - of course I've done this. You can find everything in MS SDK for JAVA v 1.5 and v. 2.0
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1221185
Some pointers might be in order:

1.- Java maps the dots (.) and the slashes (/) equaly when refering to a class. This is due to the way that packages are set up. Thus java.awt.pannel maps to the directory java/qwt/pannel.class and viceversa.

2.- A dll (JavaService in this case) must be either explicitly or implicitly loaded before it used. To load implicitly, it must be linked, via a library, at compile time (via the .def file). To load explicitly, the executable must make a call to LoadLibrary() (in C or C++).

The main point is that a DLL cannot exist on its own. It must be loaded by an executable program. Most likley, svcsetup is not loading the dll correctly (if at all).

Given the way its attempting to map TestService.class to TestService/class, its treating your program like a package and not an application.

Have you considered using a Java native code compiler on your app and runing the resulting .EXE instead? That would make life much eisier for you.
0
 

Author Comment

by:dusek
ID: 1221186
- In my opinion, svcsetup is only a tool to register the service, not to run dll at all. Anyway I don't understand the way this dll is loaded, but I think every WinNT service is a dll.

- of course EXE would be easier, but I need a server that would run cooperatively with HTML server on my WinNT and I don't know the way to run EXE when I'm not logged in.
0
 

Expert Comment

by:keegi
ID: 1221187
Sorry, if this goes too off-topic, but just FYI:

There is an utility, named SRVANY for NT which lets you use most programs as service.

For more info:  http://web.nvcom.com/srvany/

Haven't tried it myself, though.

0
 

Accepted Solution

by:
hleungta earned 100 total points
ID: 1221188
The error message you get seems to be caused by the fact that it could not find the class.
You need to define the CLASSPATH environment variable in Windows NT (Control Panel , System). The variable has to be defined for the SYSTEM, not at the user level.
If you are accessing a database (JDBC) via ODBC-JDBC bridge, make
sure that your DataSourceName (DSN) is defined in the System section (not User Data Base).
If you are accessing network drive, don't run your service using the LocalSystem account, create a new user for this purpose.

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:

808 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