We are running the Oracle standalone OC4J J2EE web application server on our Windows 2012 R2 server. The command line to start the oc4j server is as follows:
`java -jar %J2EE_HOME%\oc4j.jar`
The J2EE_HOME system-wide environment variable has been set correctly, and we are able to start the web server from the command line.
System Environment Variables:
`JAVA_HOME=C:\Progra~1\Java\jdk1.7.0_65\jre\bin`
`J2EE_HOME=E:\OC4J\j2ee\home`
Now we need to run the OC4J server as a Windows Service. To do this, we downloaded the WinRun4J open source application. Following the winrun4j directions, I've performed the following:
1) Created a new folder: E:\Custom_Apps
2) Copied the WinRun4J64 executable to the new folder
3) Renamed the WinRun4J64 executable to OC4J_WebServer
4) Copied the WinRun4J icon to the new folder and renamed it OC4J_WebServer
5) Created an initialization file in the E:\Custom_Apps folder named OC4J_WebServer.
The initialization file contains the following lines:
>working.directory=E:\Custom_Apps\working\
>vm.location=C:\Program Files\Java\jdk1.7.0_65\jre\bin\server\jvm.dll
>service.class=%J2EE_HOME%\oc4j.jar
>service.id=OC4JWebServer
>service.name=WinRun4J_OC4J_Service
>service.description=the OC4J Web Server service launched using winRun4J64.
>classpath.1=%JAVA_HOME%\*.jar
>classpath.2=e:\OC4J\*.jar
>classpath.3=e:\Software\WinRun4J\winrun4j\
>vmarg.1=-Xdebug
>vmarg.2=-Xnoagent
>vmarg.3=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
I executed the following commands at the command line to bind the icon and initializaton files to the executable:
RCEDIT64.exe /I OC4J_WebServer.exe OC4J_WebServer.ico
RCEDIT64.exe /N OC4J_WebServer.exe OC4J_WebServer.ini
Finally, I ran the OC4J_WebServer.exe --WinRun4J64:RegisterService
command to create the Windows service. I received the following error:
>E:\Custom_Apps[info] Module Name: E:\Custom_Apps\OC4J_WebServer.exe
>[info] Module INI: E:\Custom_Apps\OC4J_WebServer.ini
>[info] Module Dir: E:\Custom_Apps
>[info] INI Dir: E:\Custom_Apps
>[info] Working directory set to: E:\Custom_Apps\working
>[info] Configured vm.location: C:\Program Files\Java\jdk1.7.0_65\jre\bin\server\jvm.dll
>[info] Found VM: C:\Program Files\Java\jdk1.7.0_65\jre\bin\server\jvm.dll
>[info] Expanding Classpath: C:\Progra~1\Java\jdk1.7.0_65\jre\bin\*.jar
>[info] Expanding Classpath: E:\Software\WinRun4J\winrun4j\
>[info] Generated Classpath:
>[info] VM Args:
>[info] vmarg.0=-Xdebugvmarg.2=-Xnoagent
>vmarg.3=-Xrunjdwp:transport=dt_socket,address=8787,
>server=y,suspend=n
>[info] vmarg.1=-Djava.class.path=
>[info] Registering natives for Native class
> [warn] Could not find Native class
> [err] Could not find service class
> [err] Failed to initialize service: 1
`java.lang.NoClassDefFoundError: e:\OC4J\j2ee\home\oc4j/jar
`Caused by: java.lang.ClassNotFoundException: e:\OC4J\j2ee\home\oc4j.jar
`at java.net.URLClassLooader$1.run(URLClassLoader.java:366)
`at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
`at java.security.AccessController.doPrivileged(Native method)
`at java.net.URLClassLoader.findclass(URLClassLoader.java:354)
`at java.lang.ClassLoader.loadclass(ClassLoader.java:425)
`at sun.misc.Launcher$AppClassLoader.loadclass(Launcher.java:308)
`at java.lang.ClassLoader.loadclass(ClassLoader.java:358)
I make no claims to being a java developer, and was hoping someone could help me out. All I want to do is to be able to create a Windows service out of the java -jar %J2EE_HOME%\oc4j.jar
command.
I'd appreciate some help/insight into how to set this up.