AIInterface:Java: Difference between revisions

From Spring
Jump to navigationJump to search
Hoijui (talk | contribs)
mNo edit summary
Flozi (talk | contribs)
m 1cat
 
(17 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{AIInterface|Java|hoijui|0.1 (spring SVN)|Java|pre alpha|GNU GPL v2+}}
{{AIInterface|Java|hoijui|0.1|[http://en.wikipedia.org/wiki/Java_Virtual_Machine JVM languages]|~stable|GNU GPL v2+}}


=== Forum threads ===
== Java AI Interface Wrapper ==
 
==== Forum threads ====
*[http://spring.clan-sy.com/phpbb/viewtopic.php?f=15&t=12308 Java AI Interface for Spring]
*[http://spring.clan-sy.com/phpbb/viewtopic.php?f=15&t=12308 Java AI Interface for Spring]
*[http://spring.clan-sy.com/phpbb/viewtopic.php?f=15&t=15019 AI Interface redesign (in C)]
*[http://spring.clan-sy.com/phpbb/viewtopic.php?f=15&t=15019 AI Interface redesign (in C)]


=== Description ===
==== 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. 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/clan_sy/spring/ai/AI.java'').
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 [http://en.wikipedia.org/wiki/Java_Virtual_Machine languages supported by the JVM] like [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], [http://en.wikipedia.org/wiki/Groovy_%28programming_language%29 Groovy], [http://en.wikipedia.org/wiki/JRuby JRuby], [http://en.wikipedia.org/wiki/Jython Jython], [http://en.wikipedia.org/wiki/Scala_%28programming_language%29 Scala] or [http://en.wikipedia.org/wiki/Clojure 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'').


The source of this AI interface library can be found here: ''{spring_source}/AI/Interfaces/Java/''. It is only available in the caiinterface branch of the spring repository directory at the moment.
For reference only: '''[[AI:JAI|JAI]]''' <font color="red">DEPRECATED</font>


For reference only: '''[[AI:JAI|JAI]]''' (DEPRECATED)
==== AIs using it ====
(as of January 2009)


=== Currently supported AIs ===
Skirmish AIs:
* '''[[AI:NullJavaAI|NullJavaAI]]'''<br><br>
* '''[[AI:NullJavaAI|NullJavaAI]]'''
* '''[[AI:NullOOJavaAI|NullOOJavaAI]]'''
* '''[[AI:NullOOJavaAI|NullOOJavaAI]]'''


=== Download ===
==== Supported Platforms ====
It is only available in the ''caiinterface'' branch of the spring SNV directory at the moment. Refer to [[Building_spring#Obtaining_the_Source|Obtaining the Source]], and replace ''trunk'' with ''branches/caiinterface''.
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 ''SIGSEGV''s/''segmentation fault''s 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
[http://springrts.com/mantis/ Mantis]
to the AI sub-project.


It will come with spring soon.
==== How to compile ====
Make sure your Env-Vars are set like this (replace absolute paths according to your system):


=== Known Crashes ===
''Windows:''<br>
* None
<code>
SET JAVA_HOME=C:/Program Files/Java/jdk1.6.0
</code>


=== How to compile ===
''Linux:'' (you may want to place this in your ''~/.profile'' file)<br>
'''The easy way'''
<code>
export JAVA_HOME=/usr/jdk1.6.0
</code>
 
'''The easy way'''<br>
Use Scons or CMake (refer to [[Building_spring|Building spring]]).
Use Scons or CMake (refer to [[Building_spring|Building spring]]).


'''The hard way'''
'''The hard way'''
C part:
 
* include directories: ''{spring_source}/rts/System {spring_source}/AI/Interfaces/Java''
''C part:''
* source files: ''{spring_source}/AI/Interfaces/Java/*.c*''
* 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)
* create a dynamic loadable shared library (module)
* should compile with all C++ compilers (tested with: MinGW, GCC, Intel)
* should compile with all C++ compilers (tested with: MinGW, GCC, Intel)
tested under Linux and Win32
tested under Linux32 and Win32


Java part:
''Java part:''
TODO
* 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 ===
==== How to install/use ====
Additional software you need to have installed to be able to use Java AIs:
Additional software you need to have installed to be able to use Java AIs:
* [http://www.java.com/de/download/ Java Runtime Environment v1.5.0+ (tested with 1.6.0)]
* [http://www.java.com/de/download/ Java Runtime Environment v1.5.0+ (tested with 1.6.0)]


'''The easy way'''
Make sure your Env-Vars are set like this (replace absolute paths according to your system):
Use Scons or CMake (refer to [[Building_spring|Building spring]]).


'''The hard way'''
''Windows:''<br>
from source at ''{spring_source}/AI/Interfaces/Java/'' :
* copy libJava-0.1.so, libJava-0.1.dylib or libJava-0.1.dll to ''{spring_data_dir}/AI/Interfaces/impls/''
* copy InterfaceInfo.lua to ''{spring_data_dir}/AI/Interfaces/data/Java-0.1/''
 
Make sure your Env-Vars are set like this (replace absolute paths):
 
On Windows:<br>
<code>
<code>
SET JAVA_HOME=C:/Program Files/Java/jre1.6.0_05<br>
SET JAVA_HOME=C:/Program Files/Java/jre1.6.0
SET PATH=%JAVA_HOME%/bin;%JAVA_HOME%/bin/client;%PATH%
</code>
</code>


On Linux:<br>
''Linux:'' (you may want to place this in your ''~/.profile'' file)<br>
<code>
<code>
export JAVA_HOME=/usr/jre1.6.0_10<br>
export JAVA_HOME=/usr/jre1.6.0
export PATH=$JAVA_HOME/bin:$JAVA_HOME/bin/client:$PATH
</code>
</code>
'''Install the easy way'''<br>
Use Scons or CMake (refer to [[Building_spring|Building spring]]).
''' ... the manual way'''<br>
from: ''{spring_source}/AI/Interfaces/Java/''<br>
to: ''{spring_data_dir}/AI/Interfaces/Java/{Java-AIInterface-version}/''
* copy ''lib*.so'', ''lib*.dylib'' or ''*.dll'' to ''./''
* copy ''data/*'' to ''./''


''' [[AIs|<- Back to AI page]]'''
''' [[AIs|<- Back to AI page]]'''
[[Category:AIInterface]]
 
[[Category: AIInterface]]

Latest revision as of 18:53, 20 March 2013

Java
Developer
hoijui
Version
0.1
Language Support
JVM languages
Status
~stable
License
GNU GPL v2+
<- Back to AI Interfaces

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 ./

<- Back to AI page