Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Null pointer in Jinput Test program  (Read 1889 times)
0 Members and 1 Guest are viewing this topic.
Offline Preacher

Junior Member




Java games rock!


« Posted 2005-01-18 14:07:42 »

Hi im trying my hardest to get JInput working here and its not doing any good for my mental health >:

ive unzipped the core package into "jdk1.5.0_01\jre\lib\ext"

with jinput.jar and jutil.jar in the ext directory and the dxinput.dll and dxinput.jar in a folder named "controller" as the intro tutorials says.

i navigate to the "jdk1.5.0_01\jre\lib\ext" directory in the command window and execute the command:

java -cp jinput.jar;jutils.jar net.java.games.input.test.ControllerTextTest

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext>java -cp jinput.jar;jutils.jar net
.java.games.input.test.ControllerTextTest
Controller Env = net.java.games.input.DefaultControllerEnvironment@35ce36
Scanning jar: dxinput.jar
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/DirectInputAxis.class
Examining file : net/java/games/input/DirectInputDevice.class
Examining file : net/java/games/input/DirectInputEnvironmentPlugin.class
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Exception in thread "main" java.lang.NoClassDefFoundError: IllegalName: net/java
/games/input/DirectInputEnvironmentPlugin
        at java.lang.ClassLoader.preDefineClass(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at net.java.games.util.plugins.Plugins.processJar(Plugins.java:112)
        at net.java.games.util.plugins.Plugins.scanPlugins(Plugins.java:85)
        at net.java.games.util.plugins.Plugins.<init>(Plugins.java:73)
        at net.java.games.input.DefaultControllerEnvironment.scanControllersAt(D
efaultControllerEnvironment.java:174)
        at net.java.games.input.DefaultControllerEnvironment.scanControllers(Def
aultControllerEnvironment.java:164)
        at net.java.games.input.DefaultControllerEnvironment.access$000(DefaultC
ontrollerEnvironment.java:57)
        at net.java.games.input.DefaultControllerEnvironment$1.run(DefaultContro
llerEnvironment.java:108)
        at java.security.AccessController.doPrivileged(Native Method)
        at net.java.games.input.DefaultControllerEnvironment.getControllers(Defa
ultControllerEnvironment.java:106)
        at net.java.games.input.test.ControllerTextTest.<init>(ControllerTextTes
t.java:54)
        at net.java.games.input.test.ControllerTextTest.main(ControllerTextTest.
java:86)


ive tried using the -D option with the jinput.plugins option but java tells me the class doesn't exist

can anyone help me with this, and can anyonne make the install for this a little less painful maybe a complete introduction to jinput not an introduction scattered over many threads, it's just messy!!
Offline TheBohemian

Junior Member




Java will rule them all!


« Reply #1 - Posted 2005-01-21 19:45:14 »

Quote
Ive tried using the -D option with the jinput.plugins option but java tells me the class doesn't exist

do not use the property if you have copied the plugin jar into the controller directory. the two approaches are mutual exclusive.

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline Preacher

Junior Member




Java games rock!


« Reply #2 - Posted 2005-01-24 12:04:49 »

Hi i've tried a lot of things with the -D, without the -D

just trying

1  
java -cp jinput.jar;jutils.jar net.java.games.input.test.ControllerReadTest


gives me the same error

i can get rid of the error by unpacking the dxinput.jar and deleting the dxinput.jar.

There seems to be a bug with the plugin classloader when reading form jar files as i used the plugin code for a project last year and had the same problems.

So with the jar unpacked the demo now runns but only a blank JFrame appears HuhHuh

is Jinput not finding the dll's or something i wonder??
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline TheBohemian

Junior Member




Java will rule them all!


« Reply #3 - Posted 2005-01-24 19:20:46 »

JInput (in fact its is JUtils where the PluginClassLoader lives) does some strange stuff. I tend to avoid this strange plugin system at all and simply call:
Quote

java -cp jutils.jar:jinput.jar:somePlugin.jar -Djava.library.path=. -Djinput.plugins=the.name.of.the.PluginClass the.class.to.Run

This assumes that the native library (e.g. dxinput.dll) is in the directory from where you are calling this.
Jeff's plugin mechanism may be nice but IMHO causes to much hassle especially if you have multiple JVMs installed.

The names of the plugin classes are listed on the introduction page.

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline Preacher

Junior Member




Java games rock!


« Reply #4 - Posted 2005-01-26 09:03:53 »

Ok i removed the "controller" directory and moved the
dxinput.dll and dxinput.jar to my project directory.

Im using netbeans (i also tried from the command line) so i set my Running Projecct Arguments to

1  
-Djava.library.path=. -Djinput.plugins=net.java.games.input.DirectInputEnvironmentPlugin


and the jinput.jar and jutils.jar are both in the

1  
{java_home}/jre/libs/ext directory


and im running this code

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
/*
 * InputManager.java
 *
 * Created on 10 January 2005, 19:04
 */


import net.java.games.input.*;

/**
 *
 * @author Preacher
 */

public class InputManager {
 
  Keyboard kb = null;
 
  public static void main(String[] args){
    new InputManager();
  }
 
  /** Creates a new instance of InputManager */
  public InputManager() {
   
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cont = ce.getControllers();
 
    System.out.println("cont: " + cont.length);
     for (int i = 0; i < cont.length; i++) {
       if (cont[i].getType() == cont[i].getType().KEYBOARD) {
         kb = (Keyboard) cont[i];
      }
    }
   
    for(int i = 0; i < 100000; i++) {
      update();
    }
   
    System.out.println("done...");
   
  }// end constructor
 
  public void update(){
   
    kb.poll();
   
    Axis[] ax = kb.getAxes();
   
    for (int x = 0; x < ax.length; x++) {
      float num = ax[x].getPollData();
      if (num != ax[x].getDeadZone()) {
        if (ax[x].getName().equalsIgnoreCase("key 110")) {
          System.out.println("up arrow");
        }
      }
    }
   
  }
 
}// end class


and its not reading any controllers still and therefore throwing a null pointer when i try to poll the keyboard

any idea why its still not working??
sorry about all this it's just really annoying. Think i'll write a tutorial for jiput afte all this Smiley
Offline mk81

Junior Newbie




Java games rock!


« Reply #5 - Posted 2005-01-26 15:56:48 »

If don't you see this part on your console

1  
2  
3  
4  
5  
6  
7  
 Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/DirectInputAxis.class

. . . . . . and some more text

I'm pretty (almost) sure that it doesn't find the plugin.

@Preacher:

hi,
you asked me how I fixed my problems with jinput. . .
The solution was to build the whole thing by myself.

You assumed the problem is in the plugin classloader in utils.jar --> you're right

java.lang.NoClassDefFoundError: IllegalName: net/java/games/input/DirectInputEnvironmentPlugin

The problem is that the plugin loader uses slashes to specify the path/filename (only dots are allowed)

The code, wich you can check out from CVS, is fine. I built it and everything was fine.  I don't know if someone updated the binaries meanwhile.

my file hierarchy looks like this:

./dxinput.dll
./jinput.jar
./utils.jar
./Controller/dxinput.jar
./standard/ /* here are some testfiles*/

./ is the root from where my program is executed

this post might be useful for you too (the plugin problem):
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jinput;action=display;num=1098543727

Quote
im trying my hardest to get JInput working here and its not doing any good for my mental health >:


. . . it wasn't good for mine either
Offline Preacher

Junior Member




Java games rock!


« Reply #6 - Posted 2005-01-27 08:41:52 »

The thing is that i can get the "ControllerReadTest " up and running, but its just a blank JFrame, i presume theres supposed to be a read out of the keyboard and the mouse or something.

So the DirectInputEnvironmentPlugin mustn't be loading then as the code below is not printing out when i start the ControllerReadTest

1  
2  
3  
4  
5  
6  
7  
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/DirectInputAxis.class


and just to reiterate im typing this at the command line

1  
2  
C:\jinput>java -cp jutils.jar;jinput.jar -Djava.library.path=. net.java.games.in
put.test.ControllerReadTest


and my directory structure follows mk81's except that to overcome the error where the plugin loader doesn't find the DirectInputEnvironmentPlugin class i've unpacked the dxinput.jar.

./dxinput.dll
./jinput.jar
./utils.jar
./Controller/net/java/games/input/ *.class

Do you have a bug fixed version of jutils.jar mk81?? as would really appretiate it if i could use it to load the plugins

Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2005-04-28 02:56:44 »

The fix for the 1.5 incompatabiltyi as uplaoded some tiem ago.

However I did that with 1.5 beta.  The final JDK1.5 broke somethign ELSE  on me that kept it from compiling, s oI just uplaoded a fix for that so it can all compile again.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (35 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (48 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!