YAJSW
BaseX server can be configured to run as an always-on service in Windows (or daemon in Linux) using YAJSW.
Some Basics of YAJSW
- Each service running with YAJSW has a configuration file which lives in the
conffolder. - Installing and controlling services is done from the command line. Run a command prompt as administrator, then navigate to the folder where you placed YAJSW, e.g.
cd C:\Programs\yajsw\yajsw-stable-14.00 - If you need to change configuration of a service follow this sequence:
- Stop the service:
java -jar wrapper.jar --stop conf\wrapper.name.conf - Remove the service:
java -jar wrapper.jar --remove conf\wrapper.name.conf - Make your changes to the wrapper or application configuration.
- Install the service:
java -jar wrapper.jar --install conf\wrapper.name.conf - Start the service:
java -jar wrapper.jar --start conf\wrapper.name.conf
- Stop the service:
YAJSW comes with some helpful convenience scripts in the bat and bin folders. This set of instructions does not use these convenience scripts.
Gather the Files
- Get the latest version of BaseX. Select the ZIP Archive.
- Get the latest stable version of YAJSW.
- Get a Java runtime, e.g. from Adoptium. See Startup for the required version.
Install BaseX as Windows Service
The instructions on this page refer to YAJSW 14.00 and the ZIP distribution of BaseX. Paths and version numbers need to be adjusted to the versions you have downloaded.
Install Java
Install Java using the Java installer for your operating system.
Put Files into Position
These instructions assume you will be placing BaseX and YAJSW in C:\Programs, but you can choose a different location.
- Create folder
C:\Programs - Extract YAJSW to
C:\Programs\yajsw\yajsw-stable-14.00 - Extract BaseX to
C:\Programs\BaseX\basex
On the first start, an initial admin password is generated and written to the log; see User Management for how to change it.
Install BaseX as Service
Create wrapper config file wrapper.basex.conf and place it in the YAJSW conf folder. You can use the example below. You may need to modify this example to:
- Specify the location of
java.exe - Change the amount of memory available to BaseX from
1024m(for example,512mor2g)
# YAJSW configuration for BaseX
wrapper.java.command=C:/Program Files/Eclipse Adoptium/jdk-21/bin/java.exe
wrapper.working.dir=C:\\Programs\\BaseX\\basex
wrapper.java.app.mainclass=org.basex.BaseXHTTP
wrapper.java.classpath.1 = .\\BaseX.jar
wrapper.java.classpath.2 = .\\lib\\*.jar
wrapper.java.classpath.3 = .\\lib\\custom\\*.jar
wrapper.java.additional.1 = -Xmx1024m
wrapper.ntservice.name=BaseX
wrapper.ntservice.displayname=BaseX
wrapper.ntservice.description=BaseX XQuery database
wrapper.ntservice.starttype=DELAYED_AUTO_START
wrapper.console.loglevel=INFO
wrapper.logfile=${wrapper.working.dir}\\data\\wrapper-basex.log
wrapper.logfile.maxsize=10m
wrapper.logfile.maxfiles=10
wrapper.on_exit.0=SHUTDOWN
wrapper.on_exit.default=RESTART
The main class determines which service is started: org.basex.BaseXHTTP runs the HTTP Server, and org.basex.BaseXServer the Database Server.
After you have created the wrapper configuration file:
- Open a command prompt as administrator
- Navigate to the YAJSW folder:
cd C:\Programs\yajsw\yajsw-stable-14.00 - Install the service:
java -jar wrapper.jar --install conf\wrapper.basex.conf - Start the service:
java -jar wrapper.jar --start conf\wrapper.basex.conf
BaseX server is now running as a service, and will start automatically when Windows starts.