Mac Java Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kid Programmer
    New Member
    • Mar 2008
    • 176

    Mac Java Error

    Hello. I have been having problems using pico to develop java programs. I used all the commands in a tutorial I read saying open up terminal and type:

    cd
    mkdir java
    cd java
    pico

    and I type in the code. When I try to save it by pressing Control-O it prompts me for where it to be and it says:

    File Name to Write:

    I have no idea where to save it so I typed in /Java/. It then says:

    File Exists OVERWRITE ?

    and when I type in Y it says Error writing /Java/ is a directory. What do I do?
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by Kid Programmer
    Hello. I have been having problems using pico to develop java programs. I used all the commands in a tutorial I read saying open up terminal and type:

    cd
    mkdir java
    cd java
    pico

    and I type in the code. When I try to save it by pressing Control-O it prompts me for where it to be and it says:

    File Name to Write:

    I have no idea where to save it so I typed in /Java/. It then says:

    File Exists OVERWRITE ?

    and when I type in Y it says Error writing /Java/ is a directory. What do I do?
    Type the name of the file. Like
    Code:
    test.java
    You can also give the file a name from the beginning by calling
    Code:
    pico test.java
    Greetings,
    Nepomuk

    Comment

    • Kid Programmer
      New Member
      • Mar 2008
      • 176

      #3
      Originally posted by nepomuk
      Type the name of the file. Like
      Code:
      test.java
      You can also give the file a name from the beginning by calling
      Code:
      pico test.java
      Greetings,
      Nepomuk
      It doesn't me type anything in the prompt to overwrite or not except for Y and N.

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        Originally posted by Kid Programmer
        It doesn't me type anything in the prompt to overwrite or not except for Y and N.
        OK, do the following:
        1. type cd
        2. type mkdir java
        3. type cd java
        4. type pico
        5. write your code
        6. press Control-O
        7. type test.java
        8. press enter
        9. It won't prompt you to overwrite you the first time, after that it might. If so, type Y
        10. It won't tell you, that it's a directory

        The thing is, you were trying to write the file not in the directory but over the directory (replace the directory with the file). That's why it gives you the error.

        Greetings,
        Nepomuk

        Comment

        • Kid Programmer
          New Member
          • Mar 2008
          • 176

          #5
          Originally posted by nepomuk
          OK, do the following:
          1. type cd
          2. type mkdir java
          3. type cd java
          4. type pico
          5. write your code
          6. press Control-O
          7. type test.java
          8. press enter
          9. It won't prompt you to overwrite you the first time, after that it might. If so, type Y
          10. It won't tell you, that it's a directory

          The thing is, you were trying to write the file not in the directory but over the directory (replace the directory with the file). That's why it gives you the error.

          Greetings,
          Nepomuk
          Thank you that worked but now I have another problem. When I try to compile it I get this error after typing in cd /Java/. I type in javac test.java and it says
          error: cannot read: test.java
          1 error

          Comment

          • Laharl
            Recognized Expert Contributor
            • Sep 2007
            • 849

            #6
            Is test.java in that folder? If not, you'll need to go to the folder it is in with cd. Capitalization does matter, fyi, so /Java is different from /java.

            Comment

            • Nepomuk
              Recognized Expert Specialist
              • Aug 2007
              • 3111

              #7
              Originally posted by Kid Programmer
              Thank you that worked but now I have another problem. When I try to compile it I get this error after typing in cd /Java/. I type in javac test.java and it says
              error: cannot read: test.java
              1 error
              OK, so you did cd java (without slashes I would guess)? Then type ls and press enter. It should look something like this:
              Code:
              username@computername:~/java$ ls
              test.java
              (It will probably look a little different, but similar.)
              If you don't see test.java you're in the wrong place. If so, find that file.
              When you've made sure, you're in the right place, type
              Code:
              javac test.java
              again and, if that works, type
              Code:
              java test
              to test your program.

              Oh, and as Laharl mentioned, "Java" is not the same as "java". You created a folder called "java" in your home directory. (At least if OS X works like Linux - which it should, as OS X is Unix based.) The full path to your program is probably something like
              Code:
              /home/username/java/test.java
              Greetings,
              Nepomuk
              Last edited by Nepomuk; Apr 22 '08, 10:47 PM. Reason: Mentioning Laharls suggestion...

              Comment

              • Kid Programmer
                New Member
                • Mar 2008
                • 176

                #8
                Originally posted by Laharl
                Is test.java in that folder? If not, you'll need to go to the folder it is in with cd. Capitalization does matter, fyi, so /Java is different from /java.
                I am positive it is the right folder.

                Comment

                • Kid Programmer
                  New Member
                  • Mar 2008
                  • 176

                  #9
                  Originally posted by Kid Programmer
                  I am positive it is the right folder.
                  I finally got it to work!

                  Comment

                  • Nepomuk
                    Recognized Expert Specialist
                    • Aug 2007
                    • 3111

                    #10
                    Originally posted by Kid Programmer
                    I finally got it to work!
                    Glad, you've got it running. What was the problem?

                    Greetings,
                    Nepomuk

                    Comment

                    • Kid Programmer
                      New Member
                      • Mar 2008
                      • 176

                      #11
                      Originally posted by nepomuk
                      Glad, you've got it running. What was the problem?

                      Greetings,
                      Nepomuk
                      Apparently the files weren't being saved in the folder. I simply dragged the files into the folder and it was able to find them.

                      Comment

                      Working...