Help: HelloWorld

Discussion in 'Java' started by Ivan, Feb 28, 2006.

  1. Ivan

    Ivan Guest

    I'm trying to teach myself Java. I downloaded AND installed j2se, and
    set the JAVA_HOME path. I installed gcj as a compiler, and it seems to
    work just fine..

    But that's when all my problems start.

    I end up with a file called HelloWorld.o

    Perhaps I'm not using the compiler correctly..

    But when I type java HelloWorld.o I come up with error Exception in
    thread "main" java.lang.NoClassDefFoundError: HelloWorld/o

    Let me know what am doing wrong plz..

    Using Linux SuSE, and below is a copy of my HelloWorld script, which
    I've adequately named

    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello, World");
    Ivan, Feb 28, 2006
    1. Advertisements

  2. Ivan

    Todd.Bjorlo Guest

    You have to use the javac compiler, which comes with j2se. gcj afaik
    is a GNU Java Compiler. java and javac are parts of the j2se package.
    You have to type "javac", which should create
    "HelloWorld.class" which you can then run with the java command by
    typing "java HelloWorld"
    Todd.Bjorlo, Mar 1, 2006
    1. Advertisements

  3. Ivan

    Rhino Guest

    Please do not multipost. You posted this same question at, which is the appropriate place for newbie questions.
    Posting it here too just wastes your time and the time of people on this
    forum who don't realize you've already been answered elsewhere.
    Rhino, Mar 1, 2006
  4. You must decide which java you want to use. Compiling with gnu java and
    running with sun java won't work.

    Use `javac` from sun to compile and `java` to run your program, or use
    `gcj` to compile the program into a native executable which you run like
    any other native program. gcj compiles and links java-programs just like
    gcc compiles and links c/c++ programs; `gcj -o
    HelloWorld` and `chmod 700 HelloWorld; ./HelloWorld` should do it ...

    If you go for the sun-variant, make sure you get the sdk and not jre, as
    the latter has no compiler. It's also nice to have an IDE where you
    edit, compile and debug yor application, like NetBeans, Eclipse or
    JDeveloper (or any other IDE for that sake ...)
    Jon Martin Solaas, Mar 1, 2006
  5. Ivan

    John Bailo Guest

    Why don't you download a nice complete (java compatible) IDE like
    Eclipse...then you'd really learn something:
    John Bailo, Mar 1, 2006
  6. Ivan

    zero Guest

    Because using an IDE when you're just starting to learn is a bad idea, for
    a dozen reasons that have been discussed in this group several times.

    It may even lead to top-posting.
    zero, Mar 1, 2006
  7. If I had tried to use Eclipse instead of a simple text editor to write
    my first (several hundred) Java program(s), I think I would have

    I love Eclipse now, but it's a bit much when you're just trying to
    figure out how to tie your shoes in Java.
    Monique Y. Mudama, Mar 1, 2006
  8. Ivan

    Ivan Guest


    I've installed eclipse on my machine and after writing the hello world
    script I realized that perhaps it might be a better idea to lear nthe
    basics of java and then move on to an IDE..

    It can be a bit confusing having to learn to use two things at the same

    Not only that, but I didn't have to write

    public static void main....

    as eclipse did it for me..

    I'm sure that knowledge will come in handy in the future..
    Ivan, Mar 2, 2006
  9. Ivan

    James McGill Guest

    It's difficult to appreciate the value of a tool that solves a problem
    until you have experienced that problem. That's true for the IDE, and
    it's also true of the motivations behind many things programming that
    have an associated learning curve.

    On the other hand, I fail to see how Eclipse in particular, gets in the
    way of anything. Probably because I'm much too experienced and too
    comfortable with it to even try to see through a beginner's eyes.
    James McGill, Mar 2, 2006
  10. Ivan

    John Bailo Guest

    You're going to be using both eventually -- so why not learn the right way?
    Which is easier?

    Entering your code, and pressing a button that says Compile/Run or dealing
    with a million switches, paths, classpaths just to point things to where
    you can make it compile?


    It's the only way...
    John Bailo, Mar 2, 2006
  11. Ivan

    Ivan Guest


    I want to learn to code in Java, not to use a program that will code
    for me..

    If I do use it in the future (to make my work more efficient), I still
    want to know how to do it..
    Ivan, Mar 2, 2006
  12. I think you're making the right decision. Eclipse can do a lot for
    you, but it also takes a lot more work to set up than just firing up
    an editor.

    When you start working on projects with multiple packages, you may
    find that Eclipse or a similar IDE is pretty nice. At some point you
    will have enough classes and method names that you can't remember all
    of your own code, and at that point auto complete is quite handy.

    Anyway, Eclipse is a dog. I use it every day, but it is definitely a
    slow memory hog.
    Monique Y. Mudama, Mar 2, 2006
  13. I disagree, actually. I find that those who use an IDE, like BlueJ,
    tend to find packaging easier to get. If the IDE, like IDEA from
    JetBrains, writes good accessors, and has good warnings and other
    intentions, then they get a feel for decent code early.

    Further, NetBeans, BlueJ, and IDEA are not that much more difficult than
    a text editor, and they free you from having to understand classpath
    issues until you need to.
    I have been happier with people who learned those things early. YMMV,
    of course, and it always helps to have a mentor around who can explain
    what's what.
    I know what you mean about Eclipse. I am pretty happy with IDEA, while
    BlueJ is meant for learning OO/Java.

    Scott Ellsworth, Mar 2, 2006
  14. Ivan

    John Guest

    John, Mar 3, 2006
  15. Ivan

    x343181 Guest

    i made a site to remember things and a complier help file is at the

    hope it helps.
    x343181, Mar 3, 2006
  16. If nothing else, I think the arguments over this topic have shown there
    is no one right way.
    That's an absurd over-simplification. I have used both IDEs and command
    lines for years, and I vastly prefer the command-line.
    Keep telling yourself that.
    Jeffrey Schwab, Mar 4, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.