An updated start script for Linux which;
- Changes into the install directory
- Uses the XDG specifications for configuration and save locations creating directory as required
- Uses the system Java
The first thing I do when updating Starfarer is to delete the included JRE for two reasons. First, in the Starfarer Linux zip file all the file (not directory) permissions under the jre_linux directory are "-rwxr--rwx" world writeable and executable for some reason which is a bit of a security risk. Second, most Linux distributions include Java and provide easy updates (even with Oracles nuisance distribution restrictions). I understand it's for ease of plug and play but none of the other Java based games I have include a JRE in the download and don't really have any users stuck in their forums.
#!/bin/bash
# _ _
# ___| |_ __ _ _ __ ___ ___ ___| |_ ___ _ __
# / __| __/ _` | '__/ __|/ _ \/ __| __/ _ \| '__|
# \__ \ || (_| | | \__ \ __/ (__| || (_) | |
# |___/\__\__,_|_| |___/\___|\___|\__\___/|_|
#
XDGDIR=${XDG_CONFIG_HOME:-$HOME/.config}
GAMEDIR="${XDGDIR}/starsector"
INSTDIR="`dirname $0`" ; cd "${INSTDIR}" ; INSTDIR="`pwd`"
[[ ! -d "${XDGDIR}" ]] && mkdir -m 0755 "${XDGDIR}"
[[ ! -d "${GAMEDIR}" ]] && mkdir -m 0755 "${GAMEDIR}"
[[ ! -d "${GAMEDIR}/saves" ]] && mkdir -m 0755 "${GAMEDIR}/saves"
[[ ! -d "${GAMEDIR}/screenshots" ]] && mkdir -m 0755 "${GAMEDIR}/screenshots"
[[ ! -d "${GAMEDIR}/mods" ]] && mkdir -m 0755 "${GAMEDIR}/mods"
JARPATH="janino.jar:commons-compiler.jar:commons-compiler-jdk.jar:starfarer.api.jar:starfarer_obf.jar:jogg-0.0.7.jar:jorbis-0.0.15.jar:json.jar:lwjgl.jar:jinput.jar:log4j-1.2.9.jar:lwjgl_util.jar:fs.sound_obf.jar:fs.common_obf.jar:xstream-1.4.10.jar"
java \
-server -XX:CompilerThreadPriority=1 \
-Djava.library.path="${INSTDIR}/native/linux" \
-Xms1536m -Xmx1536m -Xss2048k \
-classpath "${JARPATH}" \
-Dcom.fs.starfarer.settings.paths.saves="${GAMEDIR}/saves" \
-Dcom.fs.starfarer.settings.paths.screenshots="${GAMEDIR}/screenshots" \
-Dcom.fs.starfarer.settings.paths.mods="${GAMEDIR}/mods" \
-Dcom.fs.starfarer.settings.paths.logs="${GAMEDIR}" \
com.fs.starfarer.StarfarerLauncher
exit 0
This was originally appended here
Separation between game data / user data topic but lost.
UPDATE 7 Feb 2013: Updated script for Starfarer to Starsector name change. Note that if you'd used the earlier starfarer version, the full path to the saved game continue is also saved in a separate
.java/.userPrefs/com/fs/starfarer/prefs.xml file so you'll need so correct the path at
<entry key="continue" value="path"/> from starfarer to starsector.
UPDATE 5 Nov 2014: Updated initial memory allocation pool to 1024M (maximum memory allocation pool was already 1024M) as default in 0.65.1a release.
UPDATE 15 Dec 2015: Added thread stack size to 1024K as default in 0.7.1a release.
UPDATE 27 Apr 2017: Note that as of 0.8a release if the system Java is not 7 then edit
data/config/settings.json and change
allowAnyJavaVersion to true.
UPDATE 4 Jun 2017: Increase memory allocations to 1536K as default in 0.8.1a release.
UPDATE 17 Nov 2018: Updated XStream jar version used in 0.9.0a release.
UPDATE 28 Mar 2021: Increase thread stack size to 2048K as default in 0.95a release.
UPDATE 27 Jan 2023: Removed "-XX:+CompilerThreadHintNoPreempt" option as depreciated in newer Java versions and only affected Solaris systems anyway.
UPDATE 22 May 2023: Ignored "-XX:MaxPermSize=128m" option added in 0.96a release as this option was removed with Java 8.
If you're trying to use Java 11 or newer (I didn't need to add any parameters for Java
, use the workarounds from forum post
Upgrading JRE, Obfuscator and
starsector-fixes by
necauqua. This was for Starsector 0.95a so some of the issues may be fixed in newer Starsector releases.