1

I would like to work with this robot class :

http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/Robot.html

for generating native system input´s, thats why i created this file:

import java.awt.Robot;

public class MouseClass {

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

            Robot robot = new Robot();

            // SET THE MOUSE X Y POSITION
            robot.mouseMove(300, 550);

 }
}

but i got this error-msg:

Exception in thread "main" java.lang.NoClassDefFoundError: robot/robot_v1
Caused by: java.lang.ClassNotFoundException: robot.robot_v1
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

I thought, the awt.robot is already integrated in eclipse? ok if not..i dont know where to download this robot-class, the only page i found is:

http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/awt/Robot.java

but thats "Robot.java" and the error-message doent change when i include this in my "src".

Any advices how i can use this robot-class?

SOLVED ,but:

i get a compilation problem

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

    at robot.robot_v1.main(robot_v1.java:5)

For this line:

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

do i have to change name´s here as well in this case?

greetings

=> SOLDED with package robot;

4
  • 1
    are you sure you are not running some of your old code? by any chance your old version of your class was names robot_1 and it was in robot package? Commented Feb 11, 2014 at 12:18
  • what do you mean exactly? my workspace: robot/src/robot/robot_v1.java is that wrong? Commented Feb 11, 2014 at 12:26
  • java file should have same name as class, so as you have your class named MouseClass in robot_v1.java file, it can't find and load your class Commented Feb 11, 2014 at 12:29
  • yea u were right! vote up! but i get an compilation problem than, updated my question above, could you refer to it? Commented Feb 11, 2014 at 12:56

1 Answer 1

1

Your issue is not related to Robot class at all. There is mismatch between your java file name and class name.

Your java class as you meantion in comment is robot/robot_v1.java and your class name is MouseClass. To make it work, all what you need to do is change your class name to be same as file which will be robot_v1 and as it is not in default package, you need to add at beginning of your file package definition, which will be for this case package robot;

Sign up to request clarification or add additional context in comments.

2 Comments

yea totally forgotten, thanks! could you refer to the compilation-problem as well? would be really nice! greetings
@user3297073 and what is a problem exactly? i'm asking as you said solved after you explained compilation problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.