AIInterface:Java
Developer | |
Version | |
Language Support | |
Status | |
License | |
Java AI Interface Wrapper
Forum threads
Description
This AI Interface is written in C, Java and AWK, and heavily relies on JNI and JNA. It allows spring to load AIs written in Java, or any of the other languages supported by the JVM like Java, Groovy, JRuby, Jython, Scala or Clojure. These AIs consist of a .jar file, which contains at least one class that implements the interface (see {spring_source}/AI/Interfaces/Java/java/src/com/springrts/ai/AI.java).
For reference only: JAI DEPRECATED
AIs using it
(as of January 2009)
Skirmish AIs:
Supported Platforms
As this interface uses JNA, it is limited to the platforms where it is available: (as of Jan 2009)
- Windows (x86/amd64)
- Linux (i386/amd64)
- OS X (ppc/i386/amd64)
- FreeBSD (i386/amd64)
- OpenBSD (i386)
- Solaris (x86/amd64/sparc/sparcv9)
As this includes all platforms and architectures that spring currently runs on, this should not cause any problems at all.
Download
It comes with a spring default install.
Source
The source can be found under {spring_source}/AI/Interface/Java/. Not all the Java source files are available under this directory, as a big part of them are generated during the build process, and are therefore only available when you generate them yourself, or in the AIInterface-src.jar in your spring installation.
Bugs
Known Crashes:
- When natively debugging (eg with GDB), you may get random SIGSEGVs/segmentation faults when using Java AIs. This is due to the JVM using SIGSEGV as a signal for garbage collection. There are two workarounds:
- recommended: issue a continue in your native debugger; if spring continues normally, it was a JVM garbage collection SIGSEGV
- use the JVM without JIT (Just In Time compilation), as the JVM does not use SIGSEGVs in this mode. This will make cause additional run-time CPU usage.
Please report bugs under Mantis to the AI sub-project.
How to compile
Make sure your Env-Vars are set like this (replace absolute paths according to your system):
Windows:
SET JAVA_HOME=C:/Program Files/Java/jdk1.6.0
Linux: (you may want to place this in your ~/.profile file)
export JAVA_HOME=/usr/jdk1.6.0
The easy way
Use Scons or CMake (refer to Building spring).
The hard way
C part:
- include directories:
- {spring_source}/rts/ExternalAI/Interface
- {spring_source}/AI/Wrappers/CUtils
- {spring_source}/AI/Interfaces/Java
- source files:
- {spring_source}/AI/Interfaces/Java/*.c*
- create a dynamic loadable shared library (module)
- should compile with all C++ compilers (tested with: MinGW, GCC, Intel)
tested under Linux32 and Win32
Java part:
- Reffer to the shell scripts for your platform: {spring_source}/AI/Interfaces/Java/bin/*.sh|.bat* Refffer to the shell scripts for your
- Or use the ant build script at: {spring_source}/AI/Interfaces/Java/bin/build.xml
How to install/use
Additional software you need to have installed to be able to use Java AIs:
Make sure your Env-Vars are set like this (replace absolute paths according to your system):
Windows:
SET JAVA_HOME=C:/Program Files/Java/jre1.6.0
Linux: (you may want to place this in your ~/.profile file)
export JAVA_HOME=/usr/jre1.6.0
Install the easy way
Use Scons or CMake (refer to Building spring).
... the manual way
from: {spring_source}/AI/Interfaces/Java/
to: {spring_data_dir}/AI/Interfaces/Java/{Java-AIInterface-version}/
- copy lib*.so, lib*.dylib or *.dll to ./
- copy data/* to ./