Society of Robots - Robot Forum
Software => Software => Topic started by: LeftHandRobotics on March 18, 2012, 10:50:38 AM
-
Hello,
I recently started watching the Stanford Robotics videos, which start with sort of a "Programming 101" using Java. I've heard great things about Java, but didn't necessarily want to learn it, since my understanding is that C++ is more common in robotics. Be that as it may ... I'm a complete newbie to programming and even newer to Java. I downloaded Netbeans and like the layout. My understanding is that with Netbeans I can click a "run" button and run the program automatically without using a command prompt and running the compiler (as this is how I've seen it on tutorials". When I initially went to run my HelloWorld I had the issue of my PATH not finding Javac. I had someone help me fix that ... now when I go to run the program I get this message...
"helloworld.HelloWorld class wasn't found in HelloWorld project."
My code is as follows ...
"class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
I'd really appreciate any help with this as I am a complete novice. I'm not sure if this has anything to do with the whole PATH/Javac mess. Lastly, I'm a finance guy and don't know next to nothing about software and robotics, just a hobby I've been getting into the last 4 months or so.... so please explain this to me like I am 6 ... hah ... because I spent about 5 hours last night reading and programming/debugging and am pretty upset that I can't get any program to run because I keep getting this message.
Thanks!!
-
I programmed in Java for about a year a long time ago. I've done my best to stay away from it since then for reasons like this. I believe that the problem here is either in how CLASSPATH is setup, or how the jar file you're running was built.
Someone else here may be able to give you a better answer, my suggestion is to learn C instead. The only platform I can think of that you need to know Java on is Beaglebone or Android. If you're using Atmel or PIC processors, I don't think Java will do you much good.
Just my $.02
Joe
-
Using Netbeans 7 on Windows XP, I did it as follows:
Create a new Java project:
File -> New Project.
Java -> Java Application.
I named the project HelloWorld. Netbeans autogenerated a 'HelloWorld' main class.
In this class, I added the code as you had it here. It looks like this now: package helloworld;
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
It ran just fine.
Some thoughts on what might be going on:
- missing 'package' declaration
- something else (I don't know, it's hard to tell without being able to look in your project ;) )
Good luck!
-
"helloworld.HelloWorld class wasn't found in HelloWorld project."
Is Your source code file named "HelloWorld.java"?