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 HelloWorld.java

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

  2. Ivan

    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 HelloWorld.java", which should create
    "HelloWorld.class" which you can then run with the java command by
    typing "java HelloWorld"
     
    , Mar 1, 2006
    #2
    1. Advertising

  3. Ivan

    Rhino Guest

    Re: HelloWorld

    "Ivan" <> wrote in message
    news:...
    > 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 HelloWorld.java
    >
    > public class HelloWorld {
    > public static void main(String[] args) {
    > System.out.println("Hello, World");
    > }
    >


    Please do not multipost. You posted this same question at
    comp.lang.java.help, 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
     
    Rhino, Mar 1, 2006
    #3
  4. Ivan wrote:
    > 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 HelloWorld.java
    >
    > public class HelloWorld {
    > public static void main(String[] args) {
    > System.out.println("Hello, World");
    > }
    >


    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 HelloWorld.java -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
    #4
  5. Ivan

    John Bailo Guest

    Why don't you download a nice complete (java compatible) IDE like
    Eclipse...then you'd really learn something:

    http://www.eclipse.org



    Ivan wrote:
    > 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 HelloWorld.java
    >
    > public class HelloWorld {
    > public static void main(String[] args) {
    > System.out.println("Hello, World");
    > }
    >
     
    John Bailo, Mar 1, 2006
    #5
  6. Ivan

    zero Guest

    John Bailo <> wrote in news::

    >
    > Why don't you download a nice complete (java compatible) IDE like
    > Eclipse...then you'd really learn something:
    >


    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
    #6
  7. On 2006-03-01, John Bailo penned:
    >
    > Why don't you download a nice complete (java compatible) IDE like
    > Eclipse...then you'd really learn something:
    >
    > http://www.eclipse.org
    >


    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
    fainted.

    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

    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Monique Y. Mudama, Mar 1, 2006
    #7
  8. Ivan

    Ivan Guest

    Hi..

    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
    time..

    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
    #8
  9. Ivan

    James McGill Guest

    On Wed, 2006-03-01 at 15:16 -0700, Monique Y. Mudama wrote:

    >
    > 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.
    >


    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
    #9
  10. Ivan

    John Bailo Guest

    Ivan wrote:

    > Hi..
    >
    > 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..


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

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


    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?


    > Not only that, but I didn't have to write
    >
    > public static void main....
    >
    > as eclipse did it for me..


    Coast.

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

    Ivan Guest

    hhmm..

    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
    #11
  12. On 2006-03-02, Ivan penned:
    > hhmm..
    >
    > 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..


    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

    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Monique Y. Mudama, Mar 2, 2006
    #12
  13. In article <>,
    "Monique Y. Mudama" <> wrote:

    > On 2006-03-02, Ivan penned:
    > > hhmm..
    > >
    > > 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..

    >
    > 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.


    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.

    > 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.


    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.

    > Anyway, Eclipse is a dog. I use it every day, but it is definitely a
    > slow memory hog.


    I know what you mean about Eclipse. I am pretty happy with IDEA, while
    BlueJ is meant for learning OO/Java.

    Scott

    --
    Scott Ellsworth

    Java and database consulting for the life sciences
     
    Scott Ellsworth, Mar 2, 2006
    #13
  14. Ivan

    John Guest

    John, Mar 3, 2006
    #14
  15. Ivan

    Guest

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

    jonjon.0catch.com

    hope it helps.
     
    , Mar 3, 2006
    #15
  16. John Bailo wrote:
    > Ivan wrote:
    >
    >>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..

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


    If nothing else, I think the arguments over this topic have shown there
    is no one right way.

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

    >
    >
    > 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?


    That's an absurd over-simplification. I have used both IDEs and command
    lines for years, and I vastly prefer the command-line.

    >>Not only that, but I didn't have to write
    >>
    >>public static void main....
    >>
    >>as eclipse did it for me..

    >
    >
    > Coast.
    >
    > It's the only way...


    Keep telling yourself that.
     
    Jeffrey Schwab, Mar 4, 2006
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mister.programmer

    Trouble compiling HelloWorld with vbc

    Mister.programmer, Feb 10, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,488
  2. the_JAVA_Rookie
    Replies:
    5
    Views:
    10,650
    Mickey Segal
    Aug 19, 2003
  3. Guest
    Replies:
    0
    Views:
    3,746
    Guest
    Jan 18, 2004
  4. gluraski

    helloworld portlet

    gluraski, Jun 9, 2005, in forum: Java
    Replies:
    0
    Views:
    401
    gluraski
    Jun 9, 2005
  5. Leo Wong

    ANN: HELLOWORLD

    Leo Wong, Jul 9, 2005, in forum: Java
    Replies:
    4
    Views:
    414
    Leo Wong
    Jul 9, 2005
Loading...

Share This Page