Compilation errors

Hi…

I am rewriting and recompiling the “ControllerReadTest.java” to learn the jinput programming. but I encounter these error and I don’t know how to fix it.

My OS is “Linux-Fedora Core 6” and “jinput.jar” is from jinput_combined_dist_20061029.zip.

the command I use to compile:
$ javac -classpath jinput.jar ControllerReadTest.java

the error I get:
ControllerReadTest.java:153: cannot find symbol
symbol : variable disabled
location: class ControllerReadTest.ControllerWindow
return disabled;
^
ControllerReadTest.java:157: cannot find symbol
symbol : variable disabled
location: class ControllerReadTest.ControllerWindow
disabled = b;
^
ControllerReadTest.java:158: cannot find symbol
symbol : variable disabled
location: class ControllerReadTest.ControllerWindow
if(!disabled) {
^
Note: ControllerReadTest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors

the source code:

public boolean disabled() {
return disabled; // >>error: line 153<<
}

private void setDisabled(boolean b) {
    disabled = b; // >>error: line 157<<
    if(!disabled) { // >>error: line 158<<
	this.setTitle(ca.getName());
	System.out.println(ca.getName()+" enabled");
    } else {

does anyone know how to fix this?
Thank you…

Looks like you’ve not defined ‘disabled’ anywhere.

Dear endolf,

thanks for your advice, it helps.

when I compile the exact same code as the source code of ControllerReadTest (from: https://jinput.dev.java.net/source/browse/jinput/coreAPI/src/java/net/java/games/input/test/ControllerReadTest.java) with:

$ javac -Xlint:unchecked -classpath jinput.jar ControllerReadTest.java

, I got these warning messages:

ControllerReadTest.java:182: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
            axisList.add(p2);
                        ^
ControllerReadTest.java:255: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
        controllers.add(new ControllerWindow(this, c));
                       ^
2 warnings

although this is only warning messages, I want to know the meaning of these warning. Please tell me the meaning of these?

when I ran the program with:

$ java -cp jinput.jar ControllerReadTest

, I got the following error messages:

Exception in thread "main" java.lang.NoClassDefFoundError: ControllerReadTest
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Caused by: java.lang.ClassNotFoundException: ControllerReadTest not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:jinput.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.7rh)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)

as I look at the source code of ControllerReadTest.java, I can see the main method at the last part of the code. Please explain me how to properly compile and run the ControllerReadTest code?

Thank you.

The warnings are because jinput works with java 1.4 and you are using java 1.5 or newer which has generics in that give you typed lists, the compiler warns you if you are compiling code with a target greater than 1.4 if you use unon typed lists.

you have added the jinput jar to the classpath, but not the file you have compiled. You should have a directory structure somewhere that matches the package structure of the class, and in there will be a .class, add the top directory to your classpath and it will work.

java -cp jinput.jar;<directory I compiled it all too> net.java.games.input.test.ControllerReadTest

Endolf

Dear endolf,

Thank you for your advice, you are my savior. ;D
It is working fine now.

about the warnings I mentioned. Could you be more specific on which line of source code is for java 1.4. and if you don’t mind, could you provide me with the solution in order to solve the warnings.

Thank you.

About 1/3 of the way down, the heading ‘Raw types and unchecked warnings’ should cover it. These are general Java questions not JInput related ones, so you could ask them on the Newbie forums.

Endolf

Dear endolf,

I got it… thanks for everything. :smiley:

See you later…