Solved

Running Java class as Win NT service

Posted on 1997-06-03
8
333 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

939 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now