Java OpenAL (JOAL)
(as of July 2007 v1.1.1)

JOAL 1.1.1 binary now comes with four files: gluegen-rt.dll, gluegen-rt.jar, joal.jar, joal_native.dll. According to Andrew Davison there is no longer any need to download OpenAL itself (apparently all that is needed is now bundled into JOAL).

(as of April 2006)

To support OpenAL audio via JOAL

OpenAL can be downloaded from Creative Labs: http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=46

JOAL can be downloaded from: https://joal.dev.java.net/

Tutorials / Lessons:


Transitioning from the "old" JOAL to the 2006+ JOAL

There have been some basic changes.

Apparently there is no longer a need to use ALut.alutUnloadWAV

Several commands now require an extra parameter, such as:

And apparently ALut.alutExit(); is no longer needed?


Configuring JOAL
(this applies for the "old" pre-2006 JOAL)

(a more descriptive explaination courtesy of a good friend)

JOAL seems to be a remarkably easy library to use if it is installed correctly.  Unfortunately, if the environment isn't correct, all one seems to get is exceptions.  When I first tried out JOAL, I thought it'd be safest to use the tutorials at https://joal-demos.dev.java.net/ as a starting point.  Unfortunately, like most tutorial code these examples are woefully inadequate.

I chose to focus on the 2nd tutorial to ensure I had a good environment.  The first problem I had was recognising whether or not OpenAL was installed on the system.  Trying to run the tutorial out of the box, I got:

>ant clean run
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\tmp\joalDemos\lesson2\classes

init:
    [mkdir] Created dir: C:\tmp\joalDemos\lesson2\classes

compile:
    [javac] Compiling 1 source file to C:\tmp\joalDemos\lesson2\classes

run:
     [java] Go TEAM!
     [java] Entering alutInit()
     [java] net.java.games.joal.OpenALException: Could not load openal library.
     [java]     at net.java.games.joal.ALFactory.init(Native Method)
     [java]     at net.java.games.joal.ALFactory.initialize(ALFactory.java:61)
     [java]     at net.java.games.joal.util.ALut.alutInit(ALut.java:61)
     [java]     at LoopingAndFadeaway.main(Unknown Source)
     [java] ALFactory.init - Native: Enter
     [java] ALFactory.init - Native: Exit

BUILD SUCCESSFUL
Total time: 5 seconds

Ok, so it's an ugly error message, but it tells me I haven't installed OpenAL.  To do that, the next step is dependent on the operating system you're using.  I'm using Windows XP currently, but also use several other operating systems.

Windows: You may find custom drivers for your card.  Or you can download from Creative Labs
Linux: Find the appropriate package for your distro.
FreeBSD: As root, run pkg_add -r openal

After doing that, I got further, but hardly what I wanted:

>ant clean run
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\tmp\joalDemos\lesson2\classes

init:
    [mkdir] Created dir: C:\tmp\joalDemos\lesson2\classes

compile:
    [javac] Compiling 1 source file to C:\tmp\joalDemos\lesson2\classes

run:
     [java] Go TEAM!
     [java] Entering alutInit()
     [java] In alutInit(): Device Name = null
     [java] #
     [java] # An unexpected error has been detected by HotSpot Virtual Machine:
     [java] #
     [java] #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4084, tid=756
     [java] #
     [java] # Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing)
     [java] # Problematic frame:
     [java] # C  0x00000000
     [java] #
     [java] # An error report file with more information is saved as hs_err_pid4084.log
     [java] #
     [java] # If you would like to submit a bug report, please visit:
     [java] #   http://java.sun.com/webapps/bugreport/crash.jsp
     [java] #
     [java] ALFactory.init - Native: Enter
     [java] ALFactory.init - Native: Exit
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 1 second

ICK!  It was really hard to figure out how to get around this.  In fact, I've only found one solution.
  1. Copy the joal.jar and joal.dll files and place them in your jre/lib/ext directory.
  2. Remove joal.dll from the project directories.  Make sure the only copy in the path or classpath is in the jre of the Java version you're using.
Finally!  It runs!

>ant clean run
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\tmp\joalDemos\lesson2\classes

init:
    [mkdir] Created dir: C:\tmp\joalDemos\lesson2\classes

compile:
    [javac] Compiling 1 source file to C:\tmp\joalDemos\lesson2\classes

run:
     [java] Go TEAM!
     [java] Entering alutInit()
     [java] In alutInit(): Device Name = null
     [java] In alutInit(): Device = net.java.games.joal.ALC$Device@9c1f50
     [java] Pointer = 10231720
     [java] ALC = net.java.games.joal.ALCImpl@42e816
     [java] Exiting alutInit()
     [java] ALFactory.init - Native: Enter
     [java] ALFactory.init - Native: Exit

BUILD SUCCESSFUL
Total time: 12 seconds

>From here, you can follow the demos and javadocs.

Old JOAL (pre 2006)

To support OpenAL audio via JOAL

The example I tried still reported "In alutInit(): Device Name = null" but then followed with a line that indicated an audio device and worked fine.

OpenAL can be downloaded from Creative Labs: http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=46

JOAL can be downloaded from: https://joal.dev.java.net/