Solved

Running Java class as Win NT service

Posted on 1997-06-03
8
332 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
Comment Utility
What is the command line that your are using to start the class?  
0
 

Author Comment

by:dusek
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 6

Expert Comment

by:jpk041897
Comment Utility
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
Comment Utility
- 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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

17 Experts available now in Live!

Get 1:1 Help Now