Results 1 to 7 of 7
- 09-30-2013, 07:17 AM #1
RyanV
- Join Date
- Sep 2013
- Location
- Manila, Philippines
- Posts
- 4
- Rep Power
- 0
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)
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")
- 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")
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!
- 09-30-2013, 09:47 AM #2
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
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
- 09-30-2013, 10:01 AM #3
RyanV
- Join Date
- Sep 2013
- Location
- Manila, Philippines
- Posts
- 4
- Rep Power
- 0
- 09-30-2013, 10:09 AM #4
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
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
- 09-30-2013, 10:39 AM #5
RyanV
- Join Date
- Sep 2013
- Location
- Manila, Philippines
- Posts
- 4
- Rep Power
- 0
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.
- 09-30-2013, 10:45 AM #6
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
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
- 09-30-2013, 10:55 AM #7
RyanV
- Join Date
- Sep 2013
- Location
- Manila, Philippines
- Posts
- 4
- Rep Power
- 0
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
-
Linked Lists Java Programming HELPP P.S. I am a beginner in Java Programming
By judemartin99 in forum New To JavaReplies: 1Last Post: 04-20-2013, 09:16 PM -
Polymorphism Java Programming HELPP P.S. I am a beginner in Java Programming
By judemartin99 in forum New To JavaReplies: 1Last Post: 04-20-2013, 09:15 PM -
android programming vs game programming using java
By vgoel38 in forum Forum LobbyReplies: 2Last Post: 09-08-2012, 12:11 AM -
Newbie iN java and need some help indeed!!
By davexc in forum Java AppletsReplies: 1Last Post: 07-13-2009, 05:34 PM
Bookmarks