Hi, I have to work with fu**ing windows xp there's xampp with tomcat plugin installed on it. I wrote a program for it that uses a rmi server to provide data which will be sent by the server pages and finally presentated by a GUI.
Now I want my server started automatically on system startup. I've allready looked at jni but there seems to be a problem with mingw-gcc and sun's dll. So I switched to jna. I downloaded jnacontrib package, compiled and packaged it. The service is installed now but I can't start it. It gives me error 1053 back when trying to start it from service control. When I try it to start from command line `java MvServer` nothing happens. I posted below the service relevant code.
MvService.java
Code:
public class MvService
extends Win32Service
{
public MvService()
{
super("MvService");
}
public void onStop()
{
}
public void onStart()
{
try{
Runtime.getRuntime().exec("rmiregistry.exe");
}catch(IOException e){
System.out.println("couldn't start rmiregistry");
}
new Thread(new Runnable(){
public void run(){
RMISecurityManager security_manager;
MvServer server;
try{
security_manager = new RMISecurityManager();
System.setSecurityManager(security_manager);
server = new MvServer();
Naming.rebind("MvServer", server);
}catch(Exception e){
e.printStackTrace();
}
}
}).start();
}
}
MvServer.java
Code:
public static void main(String[] args)
{
MvService service;
service = new MvService();
if(args.length == 1){
if(args[0].equals("install")){
service.install("Module Viewer Server",
"i-ch module viewer and overview of trainees",
null,
null,
null,
"java.exe -Djava.rmi.server.codebase=file:///c/classes/MvServer/ -Djava.security.policy=policy.txt -cp .;\\Programme\\jdom-1.1\\build\\jdom.jar;\\Programme\\Java\\jdk1.6.0_13;\\xampp\\tomcat\\lib\\servlet-api.jar;\\Programme\\jna\\jna.jar;\\Programme\\jna\\jnacontrib.jar -Xrs MvServer");
}else if(args[0].equals("uninstall")){
service.uninstall();
}else{
System.out.println("Arguments:");
System.out.println("install = install service");
System.out.println("uninstall = uninstall service");
System.out.println("<none> = run service");
}
}else{
service.init();
}
}