How to start JavaDB/Derby as a Windows Service

As I've recently started using the built-in Java DB support in GlassFish, I want the Java DB Network Server to start automatically along with GlassFish.

 I discovered that I can use the exact same method and program that's used for GlassFish-as-a-service.

On Windows, I used this script to setup a Windows Service that automatically starts the Java DB Network Server.  You can change the paths, run it once and the DB will start automatically as a service.

 

@echo off
if "%1A"=="A" goto usage
if "%2A"=="A" goto usage

echo on
sc create %1 binPath= "C:\\as\\lib\\appservService.exe \\"C:\\as\\bin\\asadmin.bat start-database --dbhome %2\\" \\"C:\\as\\bin\\asadmin.bat stop-database\\""  start= auto DisplayName= %1
goto end

:usage
echo usage createDBservice  name dbhome

:end


 

Comments:

Very Cool. Thanks for the tip.

Posted by Shreedhar on October 05, 2007 at 05:22 AM PDT #

Can you tell me how can I start JavaDB as a service without GlassFish? Just the database.

Thanks.

Posted by Marcos on December 13, 2007 at 11:04 AM PST #

C:\\as\\lib is not a windows folder, do I need to install something before I try this? Is appservService.exe included in the GF3 installation somewhere?

Posted by Joseph Chen on February 11, 2010 at 01:35 AM PST #

C:\\as\\lib was \*my\* V2 lib directory. Note how it says "change the paths..."
This blog ONLY applies to V2.

For V3 -- I'll write a new blog soon. In the meantime you should check out the useful application we use in V3 for Windows Services:

http://projectkenai.com/projects/winsw

Posted by W Byron Nevins Jr on February 11, 2010 at 02:09 AM PST #

So THATS what winsw is... lol, thanks!

Posted by Joseph Chen on February 11, 2010 at 03:22 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ByronNevins

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today