Difference between revisions of "Start Scripts"

From BaseX Documentation
Jump to navigation Jump to search
m (→‎Linux/Mac: politeness)
m (Text replacement - "syntaxhighlight" to "pre")
 
(102 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The start scripts mentioned in the [[Startup Overview|startup overview]] are also distributed via the BaseX.zip or with the Windows Installer. They can be used for every mode of BaseX and started on every operating system.
+
BaseX can be [[Startup|started in different ways]]. The [https://basex.org/download/ Windows and ZIP distributions] include various start scripts, which are presented in the following, and which can also be maintained separately.
If you didn't [http://www.basex.org/download download] or can't find them you can use the scripts below.
 
  
All modes of BaseX can be started with the following scripts (you might need to modify the path to the <code>BaseX.jar</code> archive in the script):
+
* We recommend you to manually add the {{Code|bin}} directory of your BaseX instance to the [https://en.wikipedia.org/wiki/PATH_(variable) PATH variable] of your environment.
 +
* If you use the Windows installer, that’s done automatically.
 +
* You can copy the start scripts to another location in your file system. After that, you should edit the scripts and assign the BaseX directory to the {{Code|MAIN}} variable.
 +
* If you are compiling the source code with [[Maven]], you can launch BaseX via the scripts in the [https://github.com/BaseXdb/basex/tree/master/basex-core/etc basex-core/etc] and [https://github.com/BaseXdb/basex/tree/master/basex-api/etc basex-api/etc] subdirectories of the project.
  
===Windows===
+
If BaseX terminates with an {{Code|Out of Memory}} or {{Code|Java heap space}} error, you can assign more RAM via the {{Code|-Xmx}} flag (see below). A conservative value was chosen in our distributions to ensure that BaseX will also run on older JVMs.
  
<pre class="brush:bash">
+
=Standalone=
@setlocal
+
 
 +
Use the following scripts to launch the standalone version of BaseX:
 +
 
 +
==Windows: {{Code|basex.bat}}==
 +
 
 +
<pre lang="batch">
 
@echo off
 
@echo off
 +
setLocal EnableDelayedExpansion
 +
 +
REM Path to core and library classes
 +
set MAIN=%~dp0/..
 +
set CP=%MAIN%/BaseX.jar;%MAIN%/lib/*;%MAIN%/lib/custom/*
 +
 +
REM Options for virtual machine
 +
set BASEX_JVM=-Xmx1200m %BASEX_JVM%
 +
 +
REM Run code
 +
java -cp "%CP%" %BASEX_JVM% org.basex.BaseX %*
 +
</pre>
 +
 +
==Linux/Mac: {{Code|basex}}==
 +
 +
<pre lang="bash">
 +
#!/usr/bin/env bash
 +
 +
# Path to this script
 +
FILE="${BASH_SOURCE[0]}"
 +
while [ -h "$FILE" ] ; do
 +
  SRC="$(readlink "$FILE")"
 +
  FILE="$( cd -P "$(dirname "$FILE")" && \
 +
          cd -P "$(dirname "$SRC")" && pwd )/$(basename "$SRC")"
 +
done
 +
MAIN="$( cd -P "$(dirname "$FILE")/.." && pwd )"
 +
 +
# Core and library classes
 +
CP=$MAIN/BaseX.jar:$MAIN/lib/*:$MAIN/lib/custom/*:$CLASSPATH
 +
 +
# Options for virtual machine (can be extended by global options)
 +
BASEX_JVM="-Xmx2g $BASEX_JVM"
 +
 +
# Run code
 +
java -cp "$CP" $BASEX_JVM org.basex.BaseX "$@"
 +
</pre>
 +
 +
=GUI, Server, Client=
 +
 +
If you would like to launch the GUI, Server or Client version of BaseX, please replace the class name in <code>org.basex.BaseX</code> with either <code>BaseXGUI</code>, <code>BaseXServer</code> or <code>BaseXClient</code>.
 +
 +
=HTTP Server=
 +
 +
The scripts for running [[Web Application|Web Applications]] can be found below:
 +
 +
==Windows: {{Code|basexhttp.bat}}==
  
REM Path to this script
+
<pre lang="batch">
set PWD=%~dp0
+
@echo off
 +
setLocal EnableDelayedExpansion
  
REM Paths to distributed files or source directories
+
REM Path to core and library classes
set BXPATH=basex.jar
+
set MAIN=%~dp0/..
 +
set CP=%MAIN%/BaseX.jar;%MAIN%/lib/*;%MAIN%/lib/custom/*
  
 
REM Options for virtual machine
 
REM Options for virtual machine
set VM=-Xmx1g
+
set BASEX_JVM=-Xmx1200m %BASEX_JVM%
  
REM Run BaseX
+
REM Run code
java -cp "%BXPATH%" %VM% org.basex.XXX %*
+
java -cp "%CP%" %BASEX_JVM% org.basex.BaseXHTTP %*
 
</pre>
 
</pre>
  
===Linux/Mac===
+
==Linux/Mac: {{Code|basexhttp}}==
  
<pre class="brush:bash">
+
<pre lang="bash">
#!/bin/bash
+
#!/usr/bin/env bash
  
 
# Path to this script
 
# Path to this script
PWD=`dirname $0`
+
FILE="${BASH_SOURCE[0]}"
 +
while [ -h "$FILE" ] ; do
 +
  SRC="$(readlink "$FILE")"
 +
  FILE="$( cd -P "$(dirname "$FILE")" && \
 +
          cd -P "$(dirname "$SRC")" && pwd )/$(basename "$SRC")"
 +
done
 +
MAIN="$( cd -P "$(dirname "$FILE")/.." && pwd )"
  
# Paths to distributed files or source directories
+
# API, core, and library classes
BXPATH=basex.jar
+
CP=$MAIN/BaseX.jar:$MAIN/lib/*:$MAIN/lib/custom/*:$CLASSPATH
  
# Options for virtual machine
+
# Options for virtual machine (can be extended by global options)
VM=-Xmx1g
+
BASEX_JVM="-Xmx2g $BASEX_JVM"
  
# Run BaseX
+
# Run code
java -cp "$BXPATH" $VM org.basex.REPLACEMODE "$@"
+
java -cp "$CP" $BASEX_JVM org.basex.BaseXHTTP "$@"
 
</pre>
 
</pre>
  
Note: Please replace 'REPLACEMODE' in the Java command line with the mode you want to start, which is either <code>BaseXServer</code>, <code>BaseXGUI</code>, or <code>BaseX</code>.
+
=Included Start Scripts=
[[Category:Beginner]]
+
 
 +
The BaseX [https://basex.org/download/ Windows and ZIP distributions] include the following start scripts:
 +
 
 +
{| class="wikitable"
 +
|- valign="top"
 +
! Windows
 +
! Linux/Mac
 +
! Description
 +
|- valign="top"
 +
| {{Code|basex.bat}}
 +
| {{Code|basex}}
 +
| Launches the BaseX standalone mode.
 +
|- valign="top"
 +
| {{Code|basexclient.bat}}
 +
| {{Code|basexclient}}
 +
| Starts a BaseX client.
 +
|- valign="top"
 +
| {{Code|basexgui.bat}}
 +
| {{Code|basexgui}}
 +
| Starts the BaseX GUI.
 +
|- valign="top"
 +
| {{Code|basexhttp.bat}}
 +
| {{Code|basexhttp}}
 +
| Starts the BaseX HTTP Server.
 +
|- valign="top"
 +
| {{Code|basexserver.bat}}
 +
| {{Code|basexserver}}
 +
| Starts the BaseX database server.
 +
|}
 +
 
 +
For the BaseX HTTP and database server, additional stop scripts are available:
 +
 
 +
{| class="wikitable"
 +
|- valign="top"
 +
! Windows
 +
! Linux/Mac
 +
! width="40%" | Description
 +
|- valign="top"
 +
|- valign="top"
 +
| {{Code|basexhttpstop.bat}}
 +
| {{Code|basexhttpstop}}
 +
| Stops the BaseX HTTP Server.
 +
|- valign="top"
 +
| {{Code|basexserverstop.bat}}
 +
| {{Code|basexserverstop}}
 +
| Stops the BaseX database server.
 +
|}
 +
 
 +
=Changelog=
 +
 
 +
;Version 7.5
 +
* Updated: Static dependencies removed from Windows batch scripts.
 +
 
 +
;Version 7.2
 +
* Updated: The {{Code|BaseXHTTP}} start class moved from {{Code|org.basex.api}} to {{Code|org.basex}}.
 +
 
 +
;Version 7.0
 +
* Updated: The {{Code|basexjaxrx}} scripts have been replaced with the {{Code|basexhttp}} scripts.

Latest revision as of 18:39, 1 December 2023

BaseX can be started in different ways. The Windows and ZIP distributions include various start scripts, which are presented in the following, and which can also be maintained separately.

  • We recommend you to manually add the bin directory of your BaseX instance to the PATH variable of your environment.
  • If you use the Windows installer, that’s done automatically.
  • You can copy the start scripts to another location in your file system. After that, you should edit the scripts and assign the BaseX directory to the MAIN variable.
  • If you are compiling the source code with Maven, you can launch BaseX via the scripts in the basex-core/etc and basex-api/etc subdirectories of the project.

If BaseX terminates with an Out of Memory or Java heap space error, you can assign more RAM via the -Xmx flag (see below). A conservative value was chosen in our distributions to ensure that BaseX will also run on older JVMs.

Standalone[edit]

Use the following scripts to launch the standalone version of BaseX:

Windows: basex.bat[edit]

@echo off
setLocal EnableDelayedExpansion

REM Path to core and library classes
set MAIN=%~dp0/..
set CP=%MAIN%/BaseX.jar;%MAIN%/lib/*;%MAIN%/lib/custom/*

REM Options for virtual machine
set BASEX_JVM=-Xmx1200m %BASEX_JVM%

REM Run code
java -cp "%CP%" %BASEX_JVM% org.basex.BaseX %*

Linux/Mac: basex[edit]

#!/usr/bin/env bash

# Path to this script
FILE="${BASH_SOURCE[0]}"
while [ -h "$FILE" ] ; do
  SRC="$(readlink "$FILE")"
  FILE="$( cd -P "$(dirname "$FILE")" && \
           cd -P "$(dirname "$SRC")" && pwd )/$(basename "$SRC")"
done
MAIN="$( cd -P "$(dirname "$FILE")/.." && pwd )"

# Core and library classes
CP=$MAIN/BaseX.jar:$MAIN/lib/*:$MAIN/lib/custom/*:$CLASSPATH

# Options for virtual machine (can be extended by global options)
BASEX_JVM="-Xmx2g $BASEX_JVM"

# Run code
java -cp "$CP" $BASEX_JVM org.basex.BaseX "$@"

GUI, Server, Client[edit]

If you would like to launch the GUI, Server or Client version of BaseX, please replace the class name in org.basex.BaseX with either BaseXGUI, BaseXServer or BaseXClient.

HTTP Server[edit]

The scripts for running Web Applications can be found below:

Windows: basexhttp.bat[edit]

@echo off
setLocal EnableDelayedExpansion

REM Path to core and library classes
set MAIN=%~dp0/..
set CP=%MAIN%/BaseX.jar;%MAIN%/lib/*;%MAIN%/lib/custom/*

REM Options for virtual machine
set BASEX_JVM=-Xmx1200m %BASEX_JVM%

REM Run code
java -cp "%CP%" %BASEX_JVM% org.basex.BaseXHTTP %*

Linux/Mac: basexhttp[edit]

#!/usr/bin/env bash

# Path to this script
FILE="${BASH_SOURCE[0]}"
while [ -h "$FILE" ] ; do
  SRC="$(readlink "$FILE")"
  FILE="$( cd -P "$(dirname "$FILE")" && \
           cd -P "$(dirname "$SRC")" && pwd )/$(basename "$SRC")"
done
MAIN="$( cd -P "$(dirname "$FILE")/.." && pwd )"

# API, core, and library classes
CP=$MAIN/BaseX.jar:$MAIN/lib/*:$MAIN/lib/custom/*:$CLASSPATH

# Options for virtual machine (can be extended by global options)
BASEX_JVM="-Xmx2g $BASEX_JVM"

# Run code
java -cp "$CP" $BASEX_JVM org.basex.BaseXHTTP "$@"

Included Start Scripts[edit]

The BaseX Windows and ZIP distributions include the following start scripts:

Windows Linux/Mac Description
basex.bat basex Launches the BaseX standalone mode.
basexclient.bat basexclient Starts a BaseX client.
basexgui.bat basexgui Starts the BaseX GUI.
basexhttp.bat basexhttp Starts the BaseX HTTP Server.
basexserver.bat basexserver Starts the BaseX database server.

For the BaseX HTTP and database server, additional stop scripts are available:

Windows Linux/Mac Description
basexhttpstop.bat basexhttpstop Stops the BaseX HTTP Server.
basexserverstop.bat basexserverstop Stops the BaseX database server.

Changelog[edit]

Version 7.5
  • Updated: Static dependencies removed from Windows batch scripts.
Version 7.2
  • Updated: The BaseXHTTP start class moved from org.basex.api to org.basex.
Version 7.0
  • Updated: The basexjaxrx scripts have been replaced with the basexhttp scripts.