Results 1 to 7 of 7
  1. #1
    rvvergara is offline RyanV
    Join Date
    Sep 2013
    Location
    Manila, Philippines
    Posts
    4
    Rep Power
    0

    Default Help please :( Newbie here in java programming

    Hi everyone! I am a newbie here. Thanks admins for allowing me to be a part of this. I am trying to self-teach myself programming. I am now learning the java language. And like all starters I am doing the "Hello World" kind of first program. But even in this beginning project I am facing a very tough challenge (at least for me at my level of knowledge).

    I downloaded and installed the JDK 7.0 package from Oracle (the 32-bit edition which is compatible with my 32-bit system). And then I followed all instructions in Oracle tutorials on "making the Hello World program". I first did it on Notepad then eventually on Notepad++. I tried to compile it using the following steps:

    1. I edited the Environment Variable path and added: "C:\ProgramFiles\Java\jdk1.7.0_40\bin;" (Pls see below attached titled: Environment System Variable Path editing.png for a screenshot of this)

    Help please :(  Newbie here in java programming-environment-system-variable-path-editing.png

    2.I created a sourcecode and typed with the correct syntax (even to the point of plainly copying and pasting the codes on Oracle's tutorial) and saved the file "HelloWorldApp.java"

    3. I went to Command prompt and did the ff:

    -cd C:\......\Java (the folder where I saved my source file titled "HelloWorldApp.java"
    -typed: javac HelloWorldApp.java

    it returned an error to me saying "the system cannot find the file specified"

    4. So I googled that error and found that I should either set my Environment variable Path (which I already did in Step 1) or type the whole path in the command prompt.

    5. So next time around I typed the full path: C:\ProgramFiles\Java\jdk1.7.0_40\bin\javac HelloWorld.java

    -This is the error that it returns: "The system cannot find the path specified"

    6. So I tried doing the whole thing again, but this time I did it on Notepad++. I retyped the whole code, installed the Nppexec plugin also.

    7. Pressing F6 I used Notepad++'s functions to compile and run the program (see below attached files "SourceCodeAndCompileRunAttempt1.png" and "CompileAndRunError1.png")

    Help please :(  Newbie here in java programming-sourcecodeandcompilerunattempt1.png
    Help please :(  Newbie here in java programming-compileandrunerror1.png
    - The error shown in the above mentioned attached pics are returned.

    8. So what I did was to again specify the full path to the javac and java executable files but unfortunately errors still occurred (see below attached file titled "CompileAndRunError2.png")

    Help please :(  Newbie here in java programming-compileandrunerror2.png

    What puzzles me is that I already set the Environment Variable path and added the full path to the javac. Also I checked and checked all possible coding errors and could not find any. What seems to be the problem why javac and java fail to compile and run my program? I hope for your expert advice on this.

    Thank you in advance guys!

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,743
    Rep Power
    5

    Default Re: Help please :( Newbie here in java programming

    You know that program files has a space in it, but your path doesn't.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    rvvergara is offline RyanV
    Join Date
    Sep 2013
    Location
    Manila, Philippines
    Posts
    4
    Rep Power
    0

    Default Re: Help please :( Newbie here in java programming

    Quote Originally Posted by gimbal2 View Post
    You know that program files has a space in it, but your path doesn't.
    Thanks gimbal2.

    I tried putting a space in ProgramFiles (making it Program Files) but what it says in this case is:

    C:\Program is not recognized as an internal or external command, operable program or batch file.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,743
    Rep Power
    5

    Default Re: Help please :( Newbie here in java programming

    That's the shit of paths with a space in it, you need to start to add quotes. I recommend you reinstall your Java stuff and put it in a simple folder, for example in c:\java. So you'd have something like:

    c:\java\jdk
    c:\java\eclipse
    c:\java\projects
    etc.

    Keep everything together and short, so you can't make typing mistakes.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    rvvergara is offline RyanV
    Join Date
    Sep 2013
    Location
    Manila, Philippines
    Posts
    4
    Rep Power
    0

    Default Re: Help please :( Newbie here in java programming

    I tried editing again the Environment Path Variable and put a space in Program Files there (from ProgramFiles to Program Files). Now the compiler runs good and I already have a HelloWorld.class file in the same folder I have the source file in. However, my question now is why is it that the filename for the compiled file is HelloWorld.class and not HelloWorldApp.class (HelloWorldApp is the filename I made for the source file and the compiler omitted "App" in the filename). What can be the explanation for this?

    Thanks buddy.

    Quote Originally Posted by gimbal2 View Post
    That's the shit of paths with a space in it, you need to start to add quotes. I recommend you reinstall your Java stuff and put it in a simple folder, for example in c:\java. So you'd have something like:

    c:\java\jdk
    c:\java\eclipse
    c:\java\projects
    etc.

    Keep everything together and short, so you can't make typing mistakes.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,743
    Rep Power
    5

    Default Re: Help please :( Newbie here in java programming

    Because you're breaking the well-defined and well-documented rules; the source file must have the same name as the class. And since your class is called HelloWorld, that's what your source file also must be named. But you got your tools to work, so now you can focus on the theory.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    rvvergara is offline RyanV
    Join Date
    Sep 2013
    Location
    Manila, Philippines
    Posts
    4
    Rep Power
    0

    Default Re: Help please :( Newbie here in java programming

    Thanks buddy for your replies. Truly helped me find out what was the matter. I discovered why the .class file is called HelloWorld and not HelloWorldApp. In the code I made, I typed the first line as: class HelloWorld and not class HelloWorldApp

    I was thinking that the compiler created class file name based on the file name of the source file. Apparently it got the class file name from the first line of the code. Whew, so much discovery from my very first java code! :) Was mind-boggling earlier but got more excited after I successfully ran "HelloWorld"

    So glad am part of this forum and I get to have peers that share their experiences/expertise.

Similar Threads

  1. Replies: 1
    Last Post: 04-20-2013, 09:16 PM
  2. Replies: 1
    Last Post: 04-20-2013, 09:15 PM
  3. android programming vs game programming using java
    By vgoel38 in forum Forum Lobby
    Replies: 2
    Last Post: 09-08-2012, 12:11 AM
  4. Newbie iN java and need some help indeed!!
    By davexc in forum Java Applets
    Replies: 1
    Last Post: 07-13-2009, 05:34 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •