<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.fightorder.net/wiki/index.php?action=history&amp;feed=atom&amp;title=AI%3AJAI</id>
	<title>AI:JAI - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.fightorder.net/wiki/index.php?action=history&amp;feed=atom&amp;title=AI%3AJAI"/>
	<link rel="alternate" type="text/html" href="https://www.fightorder.net/wiki/index.php?title=AI:JAI&amp;action=history"/>
	<updated>2026-04-21T05:47:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://www.fightorder.net/wiki/index.php?title=AI:JAI&amp;diff=1306&amp;oldid=prev</id>
		<title>Qrow: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.fightorder.net/wiki/index.php?title=AI:JAI&amp;diff=1306&amp;oldid=prev"/>
		<updated>2026-02-24T05:59:13Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:59, 23 February 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Qrow</name></author>
	</entry>
	<entry>
		<id>https://www.fightorder.net/wiki/index.php?title=AI:JAI&amp;diff=1305&amp;oldid=prev</id>
		<title>intermisc/gamedev&gt;Hoijui: deprecation</title>
		<link rel="alternate" type="text/html" href="https://www.fightorder.net/wiki/index.php?title=AI:JAI&amp;diff=1305&amp;oldid=prev"/>
		<updated>2010-03-03T22:07:04Z</updated>

		<summary type="html">&lt;p&gt;deprecation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{deprecated}}&lt;br /&gt;
&lt;br /&gt;
{{AI|JAI|hoijui|alpha 4 (spring SVN)|Supports All Mods|DEPRECATED|GNU GPL v2+}}&lt;br /&gt;
&lt;br /&gt;
=== Forum threads ===&lt;br /&gt;
*[http://spring.clan-sy.com/phpbb/viewtopic.php?f=15&amp;amp;t=12308 Java AI Interface for Spring]&lt;br /&gt;
*[http://spring.clan-sy.com/phpbb/viewtopic.php?f=15&amp;amp;t=15019 AI Interface redesign (in C)]&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
This AI is &amp;lt;font color=&amp;quot;FF0000&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;DEPRECATED&amp;#039;&amp;#039;&amp;#039;&amp;lt;/font&amp;gt;, see [[AIInterface:Java|Java AI Interface]] instead.&lt;br /&gt;
&lt;br /&gt;
JAI is a &amp;#039;&amp;#039;Java wrapper interface&amp;#039;&amp;#039; for the GlobalAI interface of Spring. It allows AIs to be written in Java. It is &amp;#039;&amp;#039;not&amp;#039;&amp;#039; an AI itself.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to use or even test this version, as it is based on the C++ AI interface still. Development is on hold, till the new C interface for AIs is released, after which JAI will be ported to use that interface, for greater simplicity and flexibility.&lt;br /&gt;
&lt;br /&gt;
At the time of writing (May 2008), JAI only works with SVN builds of Spring, due to a necessary change in the way Spring handles AI loading.&lt;br /&gt;
The current JAI package has been developed and tested using spring r5956.&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
* [http://spring.jobjol.nl/show_file.php?id=1022 JAI-bin.zip] - for testing JAI with the default Java AI implementation&lt;br /&gt;
* [http://spring.jobjol.nl/show_file.php?id=1021 JAI-src.zip] - for implementing your own Java AI and for testing JAI deeper&lt;br /&gt;
&lt;br /&gt;
== How to use/test it ==&lt;br /&gt;
First of all, extract the contents of JAI-&amp;lt;version&amp;gt;-bin.zip to your /spring/ directory. Note that, unlike normal AI DLLs, the JAI.dll does NOT belong directly into /spring/AI/Bot-libs, but into the /JAI subdirectory.&lt;br /&gt;
&lt;br /&gt;
Software you need to have installed to be able to run JAI:&lt;br /&gt;
* [http://java.sun.com/javase/downloads Java SDK (tested with 1.6.0)]&lt;br /&gt;
* spring r5956 (found at [http://planetspring.free.fr/spring the buildbot]), though it may also run on newer builds of spring.&lt;br /&gt;
&lt;br /&gt;
Make sure your Env-Vars are set like this:&lt;br /&gt;
&lt;br /&gt;
On Windows:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET JAVA_HOME=C:/Program Files/Java/jre1.6.0_05&amp;lt;br&amp;gt;&lt;br /&gt;
SET PATH=%JAVA_HOME%/bin;%JAVA_HOME%/bin/client;%PATH%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Linux:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
export JAVA_HOME=/usr/jre1.6.0_05&amp;lt;br&amp;gt;&lt;br /&gt;
export PATH=$JAVA_HOME/bin:$JAVA_HOME/bin/client:$PATH&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your lobby of choice does not support adding Java AIs as bots yet (until May 2008 only supported by SpringLobby), you will have to manually edit the startup script for spring.&lt;br /&gt;
A simple way to do this is the following:&amp;lt;br&amp;gt;&lt;br /&gt;
 1. Start TASClient&lt;br /&gt;
 2. Host a new game&lt;br /&gt;
 3. Set everything to your liking&lt;br /&gt;
 4. Add one or more Bots using a normal AI DLL such as AAI.dll or KAIK.dll&lt;br /&gt;
 5. Start the game and abort it using SHIFT+ESCAPE once it&amp;#039;s loaded&lt;br /&gt;
 6. Open script.txt (in the spring root directory)&lt;br /&gt;
 7. Search for aidll=&amp;lt;whatever DLL you choose&amp;gt;&lt;br /&gt;
 8. Replace it with aidll=AI/Bot-libs/tst.jar&lt;br /&gt;
 9. Open a command line window, navigate to your spring directory&lt;br /&gt;
 10. Start Spring using &amp;quot;spring.exe script.txt&amp;quot; on the command line&lt;br /&gt;
&lt;br /&gt;
If the game crashes, See [[#Bug Report|Bug Report]] below&lt;br /&gt;
If it does not, and you&amp;#039;re using the tst.jar, you can chat numbers from 1 to 7 to test the AI.&lt;br /&gt;
This is how tst.jar should react to chat numbers:&amp;lt;br&amp;gt;&lt;br /&gt;
 1 List friendly units&lt;br /&gt;
 2 Print start position&lt;br /&gt;
 3 Listing selected units&lt;br /&gt;
 4 Listing UnitDefs&lt;br /&gt;
 5 Attack: sends all units to positions of currently visible ememies&lt;br /&gt;
 6 Toggle global rally point: move units to random position after creation (default: false)&lt;br /&gt;
 7 Attack cheat: sends all units to positions of enemies&lt;br /&gt;
&lt;br /&gt;
Some of these commands may require you to switch your team to the AI&amp;#039;s, and build some units first. Do &amp;quot;/cheat&amp;quot; and then &amp;quot;/team 1&amp;quot; to achieve this.&lt;br /&gt;
&lt;br /&gt;
=== Bug Report ===&lt;br /&gt;
If the game crashes, check the various log files:&lt;br /&gt;
* AI/Bot-libs/JAI/log/&lt;br /&gt;
* AI/hoijuiAI/log/&lt;br /&gt;
* infolog.txt (spring default log file)&lt;br /&gt;
* hotspot.log (JVM log file)&lt;br /&gt;
* hserror_pid*.log (indicates a fatal JVM crash)&lt;br /&gt;
Most likely, you will not have all of them. They will be reduced in number in future versions, sorry ;-)&lt;br /&gt;
Please report any errors to hoijui in the forum or on the main lobby, thanks. Do not commit the error as a bug on mantis please.&lt;br /&gt;
&lt;br /&gt;
== Build from Source ==&lt;br /&gt;
(Hint: the whole procedure is currently a bit simpler on windows)&lt;br /&gt;
There are two makefiles available:&lt;br /&gt;
* windows (tested on XP)&lt;br /&gt;
* linux (tested on Upuntu 7.10).&lt;br /&gt;
they both compile with mingw and for windows (so they can be used to create for the official release build of spring).&lt;br /&gt;
&lt;br /&gt;
First off, you need the current spring svn version and the build environment set up for it, see [[Source_Development#Setting_up_your_development_environment|Compiling Spring]].&lt;br /&gt;
Build spring (make sure that JAI is not yet in AI/Global, as building spring would fail then).&lt;br /&gt;
&lt;br /&gt;
Software you need to have installed to be able to compile JAI:&lt;br /&gt;
* [http://java.sun.com/javase/downloads Java SDK 1.6.0+]&lt;br /&gt;
* [http://www.swig.org/download.html  SWIG 1.3.31+]&lt;br /&gt;
&lt;br /&gt;
Extract the JAI-src.zip to:&lt;br /&gt;
spring_current_svn/AI/Global&lt;br /&gt;
in the Makefile(s), you have to adjust the vars:&lt;br /&gt;
* JAVA_HOME&lt;br /&gt;
* SPRING_CURRENT_WINDOWS (only change this if you use the unix makefile)&lt;br /&gt;
on unix, you can set SPRING_CURRENT_WINDOWS to a mount of an smb shared spring on a windows PC, which needs to contains the same build as the one on unix. if you dont do this, you have to manually copy the results to your test machine on windows. As the makefile only compiles for windows, you can not test JAI on linux yet, except you adjust the makefile yourself and get it to work.&lt;br /&gt;
&lt;br /&gt;
Compile with either of the two:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;makefile -f Makefile_unix jall&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;makefile -f Makefile_win32 jall&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now have JAI ready to run, please see [[#How to use/test it|above]].&lt;br /&gt;
&lt;br /&gt;
== Creating your own implementation ==&lt;br /&gt;
To create your own implementation, it is best to use hoijui&amp;#039;s test implementaion at JAI-&amp;lt;version&amp;gt;-src.zip/src/java-impl-tst or JAI-&amp;lt;version&amp;gt;-src.zip/src/java-impl-hoijui as a start. It are minimal, sample implementations, which come with a netbeans project each.&lt;br /&gt;
A Java GlobalAI consist of one implementation for each:&lt;br /&gt;
* &amp;lt;code&amp;gt;com.clan_sy.spring.ai.global.java.AI&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;com.clan_sy.spring.ai.global.java.Factory&amp;lt;/code&amp;gt;&lt;br /&gt;
To compile, you also need JAI.jar (JAI-&amp;lt;version&amp;gt;-bin.zip/JAI) in your classpath.&lt;br /&gt;
&lt;br /&gt;
You can override methods from the superclass of TstAI.java or HoijuiAI.java to implement AI behavior. Once you are done modifying, just export your classes to a jar, and use it as your Java AI as described [[#How to use/test it|above]]. Make sure to set your new jar in step 8.&lt;br /&gt;
&lt;br /&gt;
If you need further Java libraries, put the jars into AI/Bot-libs/JAI/lib, and native libraries into AI/Bot-libs/JAI/lib aswell.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
It is possible to debugg your Java AI while it runs in spring.&lt;br /&gt;
To enable debugging, you need to save the following into file AI/Bot-libs/JAI/config.xml:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;JAI-config&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;jvm&amp;gt;&lt;br /&gt;
        &amp;lt;!-- MAIN options --&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xms4M&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xmx64M&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xss512K&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xoss400K&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;!--&amp;lt;option&amp;gt;-XX:+AlwaysRestoreFPU&amp;lt;/option&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- LOGGING options --&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-verbose:jni&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xcheck:jni&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-XX:+UnlockDiagnosticVMOptions&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-XX:+LogVMOutput&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;!--&amp;lt;option&amp;gt;-XX:LogFile=./AI/Bot-libs/JAI/log/jvm-log.txt&amp;lt;/option&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- DEBUG options --&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xdebug&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Xnoagent&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;!-- disables JIT (required for debugging under the classical VM) --&amp;gt;&lt;br /&gt;
        &amp;lt;option&amp;gt;-Djava.compiler=NONE&amp;lt;/option&amp;gt;&lt;br /&gt;
    &amp;lt;/jvm&amp;gt;&lt;br /&gt;
&amp;lt;/JAI-config&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run spring with a JAI implementation. Now you can connect with a java debugger to the machine running spring on port 7777.&lt;br /&gt;
&lt;br /&gt;
== How does it work ==&lt;br /&gt;
JAI utilizes the jvm.dll of the JRE/JDK through JNI, to create a virtual machine for the Java AI to run in.&lt;br /&gt;
It uses the same C/C++ interface as the native AIs, and just translates calls from one langauge to the other, bidirectional. Most of the sourcecode is generated with SWIG. This has the advantage that it supports a lot of other languages. One side is always C/C++, but the other could be Java, Lua, C#, Phyton, Ruby, ...&lt;br /&gt;
&lt;br /&gt;
See [http://www.swig.org SWIG Home] for further details.&lt;br /&gt;
Supporting an other language is not as easy as just switching one variable from &amp;quot;Java&amp;quot; to &amp;quot;Ruby&amp;quot; eg, but if you are desperate, you might want to use JAI as a base to support your favourite language.&lt;br /&gt;
&lt;br /&gt;
=== Used Libraries ===&lt;br /&gt;
* JVM: ...cause we are doing Java&lt;br /&gt;
* JarClassLoader: loading classes from jars at runntime (Java)&lt;br /&gt;
* Apache Commons: logging and parsing XML (Java)&lt;br /&gt;
* log4j: logging (Java)&lt;br /&gt;
* javax.vecmath.Vector3f: backend for the Java version of float3 (Java)&lt;br /&gt;
* TinyXML: parsing XML (C/C++)&lt;br /&gt;
* CMetalMap: Krogothes Metal Spot finder (C/C++)&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
* making it ready for release -&amp;gt; waiting for feedback&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; [[AIs|&amp;lt;- Back to AI page]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
[[Category:AI]]&lt;/div&gt;</summary>
		<author><name>intermisc/gamedev&gt;Hoijui</name></author>
	</entry>
</feed>