Author Topic: Class not found in Hello World Project  (Read 2707 times)

0 Members and 1 Guest are viewing this topic.

Offline LeftHandRoboticsTopic starter

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Class not found in Hello World Project
« 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!!

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: Class not found in Hello World Project
« Reply #1 on: March 18, 2012, 07:01:11 PM »
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

Offline The Headacher

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 1
Re: Class not found in Hello World Project
« Reply #2 on: March 23, 2012, 02:59:17 AM »
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:
Code: [Select]
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!
Information about my first robot: https://sites.google.com/site/theheadacher/robot (work in progress)

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Class not found in Hello World Project
« Reply #3 on: March 23, 2012, 03:47:30 AM »
"helloworld.HelloWorld class wasn't found in HelloWorld project."
Is Your source code file named "HelloWorld.java"?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

 


Get Your Ad Here