"javac": CreateProcess error=2. Please Help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    "javac": CreateProcess error=2. Please Help!

    Hi ....
    I am trying to compile my generated Java code.
    Then I am getting an error .... "javac": CreateProcess error=2.
    The command is ...
    javac -d C:/Converter/Webapps_Source_ Files/Sample/web/WEB-INF/classes -classpath C:/Converter/spring_library/spring.jar;
    C:/Converter/spring_library/servlet-2.2.jar;C:/Converter/Webapps_Source_ Files
    /Sample/web/WEB-INF/classes C:/Converter/Webapps_Source_ Files/Sample/src/java/org/iitkgp/erp/controllers
    /ViewJSP.java

    I am running it ... in Console, it's running perfectly.But whenever I trying to do it with Runtime.exec(co mmand) then I am getting this error.

    Please help!

    Debasis Jana.
    Last edited by r035198x; Mar 19 '08, 10:47 AM. Reason: the thread was looking odd
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Don't do it that way: read about the ToolProvider class and the JavaCompiler
    interface (you need Java 1.6 for them).

    kind regards,

    Jos

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by JosAH
      Don't do it that way: read about the ToolProvider class and the JavaCompiler
      interface (you need Java 1.6 for them).

      kind regards,

      Jos
      I am buliding a Code Converter Tool where I am generating some Java files and compiling those files.
      I tried it in my machine after changing the path in Windows Environment.
      It was running fine.
      But now I am runing in different machine after changing the path.
      The path is set correctly because it's running from console fine ...
      Please help.

      Debasis Jana.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by dmjpro
        I am buliding a Code Converter Tool where I am generating some Java files and compiling those files.
        I tried it in my machine after changing the path in Windows Environment.
        It was running fine.
        But now I am runing in different machine after changing the path.
        The path is set correctly because it's running from console fine ...
        Please help.

        Debasis Jana.
        The "CreateProc ess: error = 2" means that the ProcessBuilder can't find your
        executable file. You have to check your path. The tip I gave you doesn't need
        that executable file javac.exe (which simply tries to fire up another jvm; javac is
        written in java itself, remember?) But feel free to ignore my tip.

        kind regards,

        Jos

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Originally posted by JosAH
          The "CreateProc ess: error = 2" means that the ProcessBuilder can't find your
          executable file. You have to check your path. The tip I gave you doesn't need
          that executable file javac.exe (which simply tries to fire up another jvm; javac is
          written in java itself, remember?) But feel free to ignore my tip.

          kind regards,

          Jos
          How silly I am ....
          Every time i ignore your tip.
          Sorry I ll see it ....

          Debasis Jana.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by dmjpro
            Every time i ignore your tip.
            Finally .

            Comment

            • satch
              New Member
              • Feb 2008
              • 23

              #7
              Originally posted by JosAH
              The "CreateProc ess: error = 2" means that the ProcessBuilder can't find your
              executable file.
              Jos
              Hey Jos,
              I also got this error the other day. Basically an IOException was thrown and this appeared as the message. So I looked at the doc for IOException but couldn't find anything related.
              this should be there in the java docs...right? And if it is there in the java doc, where will I find it?

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by satch
                Hey Jos,
                I also got this error the other day. Basically an IOException was thrown and this appeared as the message. So I looked at the doc for IOException but couldn't find anything related.
                this should be there in the java docs...right? And if it is there in the java doc, where will I find it?
                I didn't find it in the API docs either so I experimented a bit and tried to start
                something non-existent such as "foobar"; then this error came up; I guess
                it's an OS completion code which is returned by a native method 'create' in
                a ProcessImpl class (which extends the Process class) so I lost track there.

                kind regards,

                Jos

                Comment

                • satch
                  New Member
                  • Feb 2008
                  • 23

                  #9
                  Originally posted by JosAH
                  I didn't find it in the API docs either so I experimented a bit and tried to start
                  something non-existent such as "foobar"; then this error came up; I guess
                  it's an OS completion code which is returned by a native method 'create' in
                  a ProcessImpl class (which extends the Process class) so I lost track there.

                  kind regards,

                  Jos
                  Ok.
                  Btw I also did a similar experiment, after fixing the problem by guess work :)

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Originally posted by satch
                    Ok.
                    Btw I also did a similar experiment, after fixing the problem by guess work :)
                    I guess great minds think alike ...

                    Comment

                    Working...