Solved

Running Java class as Win NT service

Posted on 1997-06-03
8
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

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

Suggested Solutions

Title # Comments Views Activity
Java string replace 11 77
ejb entity bean example issue 2 43
program arguments vs VM arguments 4 56
Tomcat 9 + java 8 error while trying to deploy a war file 2 852
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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:
This video teaches viewers about errors in exception handling.
Suggested Courses

734 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