Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Running Java class as Win NT service

Posted on 1997-06-03
8
Medium Priority
?
342 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
Industry Leaders: 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!

 

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 200 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

Industry Leaders: 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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 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:
This video teaches viewers about errors in exception handling.
Suggested Courses

596 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