Java Service Wrapper @ Wrapper Simple Intergration
From the webpage of tanukisoftware, it`s using JBoss to create a simple application to run as window services.
But for newbie, JBoss it not soo easy to understand. So after so much searching with poor result, I think better for me to ceate my own guide for all you out there who need help.
I assume you have basic knowledge on database and basic java skill.
Tools
1. TextPad free version (or notepad++ or any other text editor, you can also use Notepad but it would be better to use a text editor as it have text coloring, easy to see)
2. Java JDK latest version (or as long your application is running on your pc, then it should be fine)
3. A simple application that required running in the background with activities when log off, I have created a sample application, you can download it here.
4. 7zip (or winzip,winrar or etc)
5. Any database as (I suggested MySQL/MSSQL Express)
6. I assume you are using windows as OS
Guide
1. Download Java Service Wrapper from TanukiSoftware, download the Community Edition as it free.
2. Extract it anywhere you want but do remember where you extract it.
3. Extract the java application to C:\wrapper (you can create any name you want but i create wrapper as a folder)
4. Open the C:\wrapper folder, create this new folder inside it (bin,conf,lib,logs)
Now we go to each folder , remember on step 2 , the location of the wrapper you download earlier
5. go to the JavaServiceWrapper folder (that you extract on step 2) and go to src\bin folder, copy this file (App.bat.in , InstallApp-NT.bat.in,UninstallApp-NT.bat.in)
6. paste it on C:\wrapper\bin
7. go again to the JavaServiceWrapper folder (that you extract on step 2) and go to bin folder , copy this file (wrapper.exe)
8. Same as step 6, paste it on C:\wrapper\bin
9. go to C:\wrapper\bin and rename the file to your filename , I rename it like this (App.bat.in - MyJavaWinServices.bat, InstallApp-NT.bat.in - Install-MyJavaWinServices.bat , UninstallApp-NT.bat.in - Uninstall-MyJavaWinServices.bat)
10. Now go back to JavaSrviceWrapper folder, go to conf folder and copy wrapper.conf and paste it on C:\wrapper\conf
11. Again, go back to JavaSrviceWrapper folder, go to lib folder and copy wrapper.dll and wrapper.jar and paste it on C:\wrapper\lib
12. Go back to C:\wrapper, go to logs folder, right hand click create new txt file, rename it (with extenion) to wrapper.log
Now we need to prepared the java file, to make it as services.
* Feel free to modified my java file as you wish
info about the java app i created :
- the java program i created is a simple task that update the database in every 1min for 2 hours
- its using JDBC-ODBC connector (you need to create odbc system dsn and put the name as monitoring, and point to your database)
- currently i set it using MSSQL2005 Express database, but you can easylychange.
- i`ll include the SQL script for you , check inside the attachment
13. remember the java application you extract and put it to C:\wrapper?, now we need to create it as jar executable file.
14. before we create the executable jar, we need to declare the manifest.mtf , where you need to put the class name and also the classpath libarary to it, on the root of C:\wrapper right click and create new txt file, rename it as manifest.mft. Open it with notepad and enter this details.. dont forget to end it with an extra line ust beneath the Class-path:. line
* manifest actually point out to executables jar to look for the main class and classpath jar file
15. Now we need to package every thing to make it as executables jar. Go to command prompt (click run and type cmd , press enter) and go to wrapper folder .. type this command and press enter
16. Now you have successfully create a executbale jar file, you might want to test it by running it , do type like this.
I assume that you jar is working.. now we going to make it as window services.
17. Go to C:\wrapper\conf, open in wrapper.conf file in TextPad , we need to modified this file
18. Once wrapper.conf open, there are several lines to edit, i`ll guide you one by one (assuming you are using TextPad with linenumber enable)
- line 28 , make full link to your java path
- line 41, full link to wrapper.jar
- line 42, full link to your java lib
- line 43 , full link to the jar that you have created and test ealier
- line 46, full link to lib on your own C:\wrapper\lib
- line 61, you need to put the main class in your java application
- line 164, put the wrapper name (it will show in window services)
- line 167, put display name
- line 170, put description
- save the file
19. Now you need to test the wrapper if it is working, open C:\wrapper\bin then double click , MyJavaWinServices.bat, if you see the message is running ok (without error) that the wrapper should be working, hit Ctrl-C to close it
20. Now double click Install-MyJavaWinServices.bat to install as window services. Cick start-open-control panel-administrator and Services.. you should see you services name
21. run your services
22. just incase in the near future you need to uninstall the java services, click in the C:\wrapper\bin and click Unistall-MyJavaWinServices.bat , it will uninstall it from the list of windows services.
SO thats its... as simple as you can get...
ps: i`ll update on my next updates (there`s alot of update need to be done)
No comments:
Post a Comment