NoClassDefFoundError

Started by Kajos, August 23, 2011, 11:33:33

Previous topic - Next topic

Kajos

Hi,

I'm getting an error trying to use lwjgl.jar, lwjgl_util.jar and the native.jars.

Exception in thread "main" java.lang.NoClassDefFoundError: Cou
ld not initialize class org.lwjgl.Sys
       at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
       at project1.render.opengl.LwjglDriver.setMode(LwjglDriver.java:207)
       at project1.render.fast.Main.R_SetMode(Main.java:1039)
       at project1.render.fast.Main.R_Init(Main.java:1095)
       at project1.render.LwjglRenderer.Init(LwjglRenderer.java:72)
       at project1.client.VID.LoadRefresh(VID.java:214)
       at project1.client.VID.CheckChanges(VID.java:258)
       at project1.client.VID.Init(VID.java:328)
       at project1.client.CL.Init(CL.java:1646)
       at project1.qcommon.Qcommon.Init(Qcommon.java:130)
       at project1.project1.main(project1.java:95)

This is my jnlp file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/....etc..." href="launch.jnlp" spec="1.0+">
    <information>
        <title>jake2</title>
        <vendor></vendor>
        <homepage href=""/>
        <description>jake2</description>
        <description kind="short">jake2</description>
       
       
    </information>
    <update check="always"/>
   
    <resources>
        <j2se java-vm-args="-Xmx80M -Dsun.java2d.noddraw=true" version="1.6+"/>
        <jar href="jake2.jar" main="true"/>
       
       
    <jar href="lib/jl1.0.1.jar"/>
<jar href="lib/linux_natives.jar"/>
<jar href="lib/lwjgl.jar"/>
<jar href="lib/lwjgl_util.jar"/>
<jar href="lib/macosx_natives.jar"/>
<jar href="lib/solaris_natives.jar"/>
<jar href="lib/windows_natives.jar"/>
</resources>
    <application-desc main-class="....etc....">
       
    </application-desc>
</jnlp>

I tried categorizing native jars in their respective OS resource tag. Didnt work.

I'm trying it through Webstart. Should I not use the native jars?

Greetings,
Kajos

kappa

that error seems to suggest that it can't find lwjgl.jar.

Either way you're using the native jars incorrectly, when using natives in a jnlp you want something like
Quote
<security>
   <all-permissions/>
 </security>

 <resources>
   <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
    <jar href="jake2.jar" main="true"/>
    <jar href="lib/jl1.0.1.jar"/>
    <jar href="lib/linux_natives.jar"/>
    <jar href="lib/lwjgl.jar"/>
    <jar href="lib/lwjgl_util.jar"/>
 </resources>

<resources os="Windows">
   <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
   <nativelib href="lib/windows_natives.jar"/>  
 </resources>

 <resources os="Linux">
   <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
   <nativelib href="lib/linux_natives.jar"/>
 </resources>

 <resources os="Mac OS">
   <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
   <nativelib href="lib/macosx_natives.jar"/>
 </resources>

Kajos

That works, thanks.

Can you explain why it works from webstart but not when I run it as java -jar from the commandline?
It throws me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Cou
ld not initialize class org.lwjgl.Sys
        at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
        at project.render.opengl.LwjglDriver.setMode(LwjglDriver.java:207)
        at project.render.fast.Main.R_SetMode(Main.java:1039)
        at project.render.fast.Main.R_Init(Main.java:1095)
        at project.render.LwjglRenderer.Init(LwjglRenderer.java:72)
        at project.client.VID.LoadRefresh(VID.java:214)
        at project.client.VID.CheckChanges(VID.java:258)
        at project.client.VID.Init(VID.java:328)
        at project.client.CL.Init(CL.java:1646)
        at project.qcommon.Qcommon.Init(Qcommon.java:130)
        at project.Project.main(Project.java:95)

kappa

you can't run your jar on its own since it depends on lwjgl, natives etc, hence you get the error, so instead of "java - jar youjar.jar" you need to use something like the following on the command line

java -cp .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\jinput.jar; -Djava.library.path=native\windows

Kajos

Okay, makes sense.
And if my LWJGL dependent code is compiled at runtime by the JavaCompiler API, do you know what troubles I might get it? I'm trying it and get errors that it can't find the package of LWJGL.


/sound/lwjgl/Channel.java:43: package org.lwjgl.openal does not exist
/sound/lwjgl/Channel.java:44: package org.lwjgl.openal does not exist
/render/opengl/LwjglDriver.java:37: package org.lwjgl does not exist
/render/opengl/LwjglDriver.java:38: package org.lwjgl.opengl does not exist
/render/opengl/LwjglDriver.java:39: package org.lwjgl.opengl does not exist
/render/opengl/LwjglGL.java:5: package org.lwjgl.opengl does not exist
/render/opengl/LwjglDriver.java:52: cannot find symbol

kappa

no idea about JavaCompiler API but i'd guess that its not finding lwjgl.jar (maybe its not on the classpath) hence throwing that error.

Kajos

And can I access the LWJGL functions from unsigned code? Assuming the LWJGL libraries are signed?

kappa

Quote from: Kajos on August 25, 2011, 21:23:20
And can I access the LWJGL functions from unsigned code? Assuming the LWJGL libraries are signed?
yes

Kajos

Are you sure? If I can call org.lwjgl.sys.initialize succesfully without exceptions, does that garanty this? Reason I'm asking is because I'm having trouble reaching some other code (System.getProperty) in signed jar from unsigned code.

CodeBunny

"System.getProperty" is part of the core JVM libraries, and there should be no way in hell that you can't call it. What do you mean? :/

Kajos

I dont have the PropertyPermission when calling it from unsigned code. Even though the getProperty function relies in signed code, it gives me a PropertyPermission exception (when calling from unsigned code). I would figure this should not be the case since it relies in signed code, thats why I asked.

kappa

you should also try an accesscontroller around your signed code

e.g.

AccessController.doPrivileged(new PrivilegedAction<Object>() {
			public Object run() {
				return System.getProperty("yourProperty");
			}
		});

Kajos

Thanks! Learned something again!