New User needs Help

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

New User needs Help

Postby trella » Fri Jan 16, 2009 2:02 pm

Hiho,


just got some Problem when using program-snippets that are using Exeptions.
For Example:

Code: Select all
import lejos.nxt.*;

public class BatteryTester {
    public static void main(String[] args) throws Exception {
   


        LCD.drawString("Battery: " + Battery.getVoltage() + " Volt", 0, 0);
        LCD.drawString("Battery: " + Battery.getVoltageMilliVolt() + " mVolt", 0, 1);
        Thread.sleep(5000);

    }
    }



When trying to compile i always get:
Code: Select all
Compiliere C:\java-src\BatteryTester.java mit Java-Compiler (Mindstorms-Modus)
.\Exception.java:1:1: class or interface expected
try {
^
.\Exception.java:6:5: class or interface expected
    throw e; //Leite nach oben weiter
    ^
.\Exception.java:7:1: class or interface expected
} catch (Exception e) {
^
.\Exception.java:10:1: class or interface expected
} catch (OutOfMemoryError e) {
^
.\Exception.java:13:1: class or interface expected
} catch (Throwable t) {
^
.\Exception.java:16:1: class or interface expected
} finally {
^
.\Exception.java:19:1: class or interface expected
}
^
BatteryTester.java:4:51: cannot access Exception
bad class file: .\Exception.java
file does not contain class Exception
Please remove or make sure it appears in the correct subdirectory of the classpath.
    public static void main(String[] args) throws Exception {
                                                  ^

Thanks in advance for your help.
trella
New User
 
Posts: 5
Joined: Fri Jan 16, 2009 1:59 pm

Postby ChrisB01 » Fri Jan 16, 2009 3:32 pm

The code seams fine for me. Can you give a description of the command you're using? (I assume your using the command line), what version of lejos are you running?, have you got classes.jar on the classpath?.

Thanks,

Chris
ChrisB01
Advanced Member
 
Posts: 189
Joined: Sat Mar 15, 2008 12:19 pm
Location: UK

Postby lawrie » Sat Jan 17, 2009 3:56 pm

It looks like you have a file called Exception.java in the same folder as BatteryTester.java. You should remove Exception.java. Do you have such a file? If so, what are you trying to do with it?
lawrie
leJOS Team Member
 
Posts: 835
Joined: Mon Feb 05, 2007 1:27 pm

Postby trella » Fri Feb 06, 2009 12:53 pm

Thanks a lot. Indeed there was a Exception. java in the wrong place^^
trella
New User
 
Posts: 5
Joined: Fri Jan 16, 2009 1:59 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff