Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0

    Javac: file not found : world.java


    My java compiler is not finding the hello world.java file that i have saved on my desktop. I've done research and most posts say something about setting my environmental variables such as PATH and CLASSPATH. Could someone please explain to me how to do this and give me good beginner definitions of what these two variables are and why they are important to the compiler? I am using a macbook pro and my text editor is bbedit. I have tried the helloworld program in two text editors including this one and i get the same result in terminal. Thanks for the help.
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    How are you trying to compile it?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by bullet
    How are you trying to compile it?
    I am in terminal using the command, javac hello world.java.
    My file is saved case sensitively to the class name but when i use that command, it comes up with that error. Im reading how to set my javac/jdk to the PATH variable but i can't seem to figure it out. I think this is the problem.
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,673
    Rep Power
    1958
    You should not have space in the name of of the file/class, but limit it to only contain the letters a-z (A-Z).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by MrFujin
    You should not have space in the name of of the file/class, but limit it to only contain the letters a-z (A-Z).
    OK, so if i should not save the file as hello(space)world.java, but helloworld.java.
    i will try now.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by Logan Betz
    OK, so if i should not save the file as hello(space)world.java, but helloworld.java.
    i will try now.
    i changed the class name to helloworld instead of hello world and i changed the file name accordingly. when i typed javac helloworld.java in terminal the same thing came up. "javac: file not found : helloworld.java"
    this did fix the problem of having terminal pick up on the whole file name instead of just the last word "world" though. so that helps.
  12. #7
  13. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,673
    Rep Power
    1958
    are you in the correct folder? call dir before javac and check that the file is listed.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by MrFujin
    are you in the correct folder? call dir before javac and check that the file is listed.
    im sorry, what do you mean call dir? what exactly should i write in terminal and how should it look afterwards?
  16. #9
  17. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    Originally Posted by Logan Betz
    im sorry, what do you mean call dir? what exactly should i write in terminal and how should it look afterwards?
    For the mac, you would type

    Code:
    ls -l *.java
    To see the .java files.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by bullet
    For the mac, you would type

    Code:
    ls -l *.java
    To see the .java files.
    http://i539.photobucket.com/albums/f...inaldirtry.png

    This is what i got when i tried entering the code you just gave me.
  20. #11
  21. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    Originally Posted by Logan Betz
    http://i539.photobucket.com/albums/f...inaldirtry.png

    This is what i got when i tried entering the code you just gave me.
    That means you don't have any .java files in the current directory. Where do you have the file?
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by bullet
    That means you don't have any .java files in the current directory. Where do you have the file?
    i have it saved onto my desktop. how would i get the file into my directory and how do i find my directory in the first place?
  24. #13
  25. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    Originally Posted by Logan Betz
    i have it saved onto my desktop. how would i get the file into my directory and how do i find my directory in the first place?
    At the prompt, try typing

    Code:
    cd Desktop
    and then

    Code:
    ls -l *.java
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    18
    Rep Power
    0
    Originally Posted by bullet
    At the prompt, try typing

    Code:
    cd Desktop
    and then

    Code:
    ls -l *.java
    patricias-MacBook-Pro:~ patriciabetzschiff$ cd desktop
    patricias-MacBook-Pro:desktop patriciabetzschiff$ ls -l *.java
    -rw-r--r--@ 1 patriciabetzschiff staff 253 May 5 12:33 helloworld.java

    so it looks like that its recognized on the desktop. but what do i do next and by the way, what is recognizing it through that command, what is cd?
  28. #15
  29. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,022
    Rep Power
    1285
    cd means change directory.

    You should now be able to compile and execute the program with

    Code:
    javac helloworld.java
    and

    Code:
    java helloworld
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo