PDA

View Full Version : Java KeyboardReader Problem


Andrey:)
26th January 2006, 11:15 PM
Hello guy, iam newbie with Java and trying to learn.
I was expiriwncing problems with KeyboardReader method. So i thought it was due to old version of Java libs but i have updated them all . Whenever i write some program where KeyboardReader method needs to be used, after succsesfull compilation the program gives me this eror :


[root@localhost Java]# javac KbRdPr.java
[root@localhost Java]# java KbRdPr
Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: KeyboardReader
at java.lang.VMClassLoader.transformException(java.la ng.Class, java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Cla ss) (/usr/lib/libgcj.so.6.0.0)
-bash: [root@localhost: command not found
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
at KbRdPr.main(java.lang.String[]) (Unknown Source)
at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.lang.ClassNotFoundException: Script not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(java.lang.String ) (/usr/lib/libgcj.so.6.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
...5 more

Could it be Because of my KeyboardReader.class file is in the same directory or does it need to be placed in particular directory?
Please help newbie.:)

Shakes
26th January 2006, 11:21 PM
You're talking like KeyboardReader is a method but it seems to think that it should be a class. I don't see the class in the api. If it's a third party thing that your using then you need to make sure it's in your classpath. Do you want to paste some code?

Andrey:)
26th January 2006, 11:24 PM
So how do i do that ?

Shakes
26th January 2006, 11:37 PM
Actually I don't thnk that your classpath will be wrong since ti compiled. Can you copy and paste your code or attach it as a file?

Andrey:)
26th January 2006, 11:59 PM
//
//To check functionality of keyboardreader


class KbRdPr

{
public static void main (String args[])
{
KeyboardReader kb = new KeyboardReader();

double a, b, c;

System.out.println("Please Enter Number:");
a=kb.getDouble();
System.out.println("plese again:");
b=kb.getDouble();
c=a*b;
System.out.println("result:" + c);
}
}


This is the program that iam tring to run. The KeyboardReader.class file atached as i downloaded alrerady compiled . Could that be a problem? :confused:

Andrey:)
27th January 2006, 02:42 AM
Finaly
I sorted it out:
i needed to download The update form Sun for J2SE(TM) Runtime Environment 5.0 .
The information found here http://stanton-finley.net/fedora_core_4_installation_notes.html#Java found EXTREMLY USEFULL.

And i kept the KeyboardReader in the same directory:)

Thanx for your help.
Andrey

Volgograd Travel Photos on Instagram - Saijo Travel Photos - Minden Instagram Photos