4 Replies Latest reply: Mar 10, 2007 4:38 AM by 807599 RSS

    java file compilation problem..

    807599
      hello...
      i placed all my java file in the folder C:\nmt
      and i run the following command to compile it...
      javac -sourcepath C:\nmt testabc.java
      now it showing an error..
      cannot read testabc.java
      javac -sourcepath C:\nmt -d C:\nmt testabc.java
      to produce the output in the C:\nmt folder but it shows the same message...
      now change the format of the command...
      javac -soucepath <C:\nmt>testabc.java
      now it says..
      access denied...
      now can u pls tell me whats wrong i am doing here...
      is there any problem in my os...
      i loged on as Administrator...
      why its saying access denied...
      and trust me that folder do have the java file..testabc.java..
      pls help me...

      btw ...i am using java 6...

      Message was edited by:
      samriddh
        • 1. Re: java file compilation problem..
          807599
          (1) On the command line line navigate to the folder containing your ,java source files
          c:\
          cd nmt
          (2) Verify that you hava a java compiler available
          javac -version
          (3) Verify that the .java file exists
          type testabc.java
          (4) Compile the .java file
          javac -cp . testabc.java
          (5) Run the program
          java -cp . testabc
          If you get stuck post these commands and their output.

          (You should change the name of your class to something that starts with a capital
          letter - either Testabc or TestAbc.)
          • 2. Re: java file compilation problem..
            807599
            thanx for answering...
            okk tried ur commands...
            the outputs are following...
            javac -version
            'Javac' is not recognized as a internal or external command
            type testabc.java
            import java.io.*;
            class Testabc
            {
            public static void main(String args[])
            {
            System.out.println("Hello World");
            }
            }

            javac -cp . testabc.java
            'Javac' is not recognized as a internal or external command

            but java -version gives the output..
            the version details....JDK1.6.0 etc....
            do i have to copy the javac compiler to this folder from jdk\bin...
            waiting for ur rply...

            sam
            • 3. Re: java file compilation problem..
              807599
              javac -version
              'Javac' is not recognized as a internal or external command
              Bingo! We have a winner!
              do i have to copy the javac compiler to this folder from jdk\bin...
              No, don't do that.

              What you should do is add the location of the java tools (java.exe and javac.exe)
              to your system's PATH. How to do this is nicely documented here:
              http://java.sun.com/javase/6/webnotes/install/jdk/install-windows.html#Environment
              Follow the steps (a->c) in section 4 "Update the PATH variable"

              Then try the commands I posted once again.

              A few little thoughts:

              (1) I got the first couple of commands wrong, they should be
              c:
              cd \nmt
              (2) If anything goes wrong, cut, paste and post the actual output from the terminal
              ("Cmd Window" or whatever it's called). Don't leave anything out and don't trust your
              own typing not to make any typos.

              (3) Your class is called Testabc (with a capital 'T'). Make sure that the file is named
              Testabc.java (with a capital 'T'). It makes a difference, even with Windows. Also
              change all the commands in my previous post, so that they refer to Testabc.
              • 4. Re: java file compilation problem..
                807599
                thnx...it worked fine...after setting the path variable...
                thnx for ur rplys....
                sam