views:

147

answers:

3

Hi,

I'm having a bunch of problems getting this library to work on my OSX installation. In particular, I'd like to use it with a Java 1.6 VM but after I compile it up I get the following:

java -cp "luajava-1.1.jar" org.keplerproject.luajava.Console
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/dharabor/src/luajava- 1.1/libluajava-1.1.jnilib: 
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1739)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1030)
    at org.keplerproject.luajava.LuaState.<clinit>(LuaState.java:92)
    at org.keplerproject.luajava.LuaStateFactory.newLuaState(LuaStateFactory.java:59)
    at org.keplerproject.luajava.Console.main(Console.java:49)

I'm running OSX 10.5.8 with Lua 5.1.4 I've also changed my OSX default VM to 1.6.0 as so:

/System/Library/Frameworks/JavaVM.framework/Home -> Versions/1.6.0/Home/
/System/Library/Frameworks/JavaVM.framework/Versions/Current -> 1.6.0/
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> 1.6.0/

What am I doing wrong? I notice when I use Java 1.5 everything works great. Except I don't want 1.5, I want 1.6.

A: 

This may be a clue, from jnlua on luaforge, Section 7. Building the Native Library:

Note that building for the macos64 platform with LuaBinaries is currently not supported. This is due to Java 6 on Mac OS being only 64-bit and LuaBinaries providing only 32-bit libraries for that platform.

I couldn't find any other direct reference to this, but it seems a plausible explanation, given the symptoms you describe. LuaJava uses LuaBinaries.

martin clayton
A: 

The problem is that Apple only released a 64 bit version of Java 6 on Leopard, which means that all .jnilib files (and associated dependencies) need to be/contain 64 bit. Java 5 on Leopard has both 32 and 64 bit versions. Even more confusing is the fact that Snow Leopard has both 32 and 64 bit versions of Java 6.

So, to summarize:

  • Leopard:
    • Java 5: 32 & 64
    • Java 6: 64
  • Snow Leopard:
    • Java 6: 32 & 64
Simeon Fitch
A: 

I just got it to work this morning following these old directions by Joe Huges: http://retrovirus.com/incr/2005/08/building-luajava/ (Some slight modifications were necessary). I'm using 10.6 on a 2007-vintage (32 bit) MBP.

The problem you describe was solved by moving the libluajava-1.1.jnilib Java library to the /Library/Java/Extensions/ folder. The -cp "luajava-1.1.jar" flag adds the jar file to your path, but the library still needs to be added.

reemrevnivek