Load External Java Library

Load External Java Library

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
msm8bball
Posts: 52
Joined: 09 Oct 2009, 08:08

Load External Java Library

Post by msm8bball » 22 May 2016, 01:06

My AI deploys and runs without crashing. I want to utilize a library in an external JAR file (signalr-client-sdk.jar). I've placed the JAR file in the /jlib directory under my AI, alongside vecmath.jar and JavaOO-AIWrapper.jar etc. I add a line of code in my AI's init method instantiating an instance of a class from the JAR file.

My code compiles fine in Netbeans with this instantiation line. But it crashes my AI in Spring. I think it's not seeing my JAR file. How do I make it aware of it? Here's my infolog.txt snippet:

Code: Select all

[f=-000001] [Java Interface] JRE found in env var "JAVA_HOME"!
[f=-000001] [Java Interface] Using JRE (can be changed with JAVA_HOME): C:\Program Files (x86)\Java\jdk1.8.0_91\jre
[f=-000001] [Java Interface] Successfully loaded the JVM shared library at "C:\Program Files (x86)\Java\jdk1.8.0_91\jre\bin\client\jvm.dll".
[f=-000001] [Java Interface] Unable to find common read-only data-dir (optional).
[f=-000001] [Java Interface] Unable to find common read-only native libs data-dir (optional).
[f=-000001] [Java Interface] Initialization successfull.
[f=-000001] Warning: AI for team 0 (ID: 0) failed handling event with topic 1, error: -5
[f=-000001] Error: Failed to handle init event: AI for team 0, error -5
[f=-000001] [WatchDog] deregistering controls for thread [load]
[f=-000001] Loaded DecalsDrawer: Legacy
[f=-000001] GameID: 2ce64057eb992dc92109bfd6a4e560fe
[f=-000001] Connection attempt from msm8bball
[f=-000001]  -> Version: 101.0.1-373-g9d13eb6 develop
[f=-000001]  -> Connection established (given id 0)
[f=-000001] Player msm8bball finished loading and is now ingame
[f=-000001] Skirmish AI "Bot1" (ID:0), which controlled team 0 is now dead
[f=0000130] [QuitBox] user exited to system
Note, I'm using the 101.0.1-373-g9d13eb6 development build as it fixed an issue with loading Java AI's.
0 x

msm8bball
Posts: 52
Joined: 09 Oct 2009, 08:08

Re: Load External Java Library

Post by msm8bball » 22 May 2016, 05:20

It turns out that while my project was building successfully, the signalr-client-sdk.jar I was calling needed two additional JARs (Google's JSON library and Java Web Sockets library). This only became apparent at runtime once I made a standalone Java executable tried to use signalr-client-sdk.jar. My problem is solved, but perhaps this would be easier if the AI interface could capture this error better?
0 x

abma
Spring Developer
Posts: 3560
Joined: 01 Jun 2009, 00:08

Re: Load External Java Library

Post by abma » 27 May 2016, 07:49

msm8bball wrote:this would be easier if the AI interface could capture this error better?

what do you mean with "this"?
0 x

msm8bball
Posts: 52
Joined: 09 Oct 2009, 08:08

Re: Load External Java Library

Post by msm8bball » 28 May 2016, 23:43

abma wrote:
msm8bball wrote:this would be easier if the AI interface could capture this error better?

what do you mean with "this"?
I mean debugging to figure out what was wrong would be easier if it was able to give a more descriptive error message.
0 x

abma
Spring Developer
Posts: 3560
Joined: 01 Jun 2009, 00:08

Re: Load External Java Library

Post by abma » 30 May 2016, 16:54

there seems to be no easy way to print such info to infolog.txt, needs some work on the interface:

http://stackoverflow.com/questions/2054 ... -exception
0 x

Post Reply

Return to “AI”