Wrong directory in Notepad++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lolv007
    New Member
    • Apr 2010
    • 3

    Wrong directory in Notepad++

    I am a complete rookie at programming, and I've installed NotePad++ on my laptop so I can practise writing scripts outside of uni. I've also installed JDK v 1.6.0 (Java Development Kit), JRE and JDK Documentation onto my laptop.

    My problem is that when I try to compile my program in NotePad++ (before I run the application), I get an error saying

    CreateProcess() failed with error code 2:
    The system cannot find the file specified.

    I don't know how to fix this, or where to begin to try and fix it, so any help on this would be awesome!
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Can you tell me what's broken on my car without seeing my car?
    Maybe yes if you are a fortune-teller. But I am not.
    So please show your program, and how you tried to compile it.
    Then we can see what file you specified could not be found.

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      There's no need to be so patronizing. This is probably an issue with the Notepad++ setup, thus not dependent on the code.

      Can your program compile the simplest of code? eg :
      Code:
      public class Main {
      	public static void main(String[] args)  {}
      }
      You probably just need to set it up to point to the proper java compiler on your computer. Double check the compile time options.

      Comment

      • lolv007
        New Member
        • Apr 2010
        • 3

        #4
        I think it is a problem with my set-up. I've tried compiling the most simplest of codes, but it still comes up with the same error. I'm not sure how to change the java compiler (as I said, I'm a complete rookie at this :) ). Do I have to change something under in Macro>NppExec tab?

        Comment

        • chaarmann
          Recognized Expert Contributor
          • Nov 2007
          • 785

          #5
          Sorry that it sounded patronizing. Maybe I was in that mood because of so many people making a guessing game: asking for help in their program and not listing their source code or command that lead to the error. My apologies, I should not put all under one umbrella.

          If it's a Notepad++ configuration issue, then we really don't need the source code and I am of no help, since I am using jEdit and Eclipse. But in case that it's a general compilation issue (what I bet it is), it would be very helpful for me to give me following information:
          • The compilation command: Somewhere inside the configuration of Notepad++ there must be the command line given for compilation. Something like "javac -classpath ... %1" or so. Please list it here. Maybe this line contains references (directly or through CLASSPATH) to files that are not there.
          • the CLASSPATH and PATH environment variable. Maybe the compiler cannot be found because it's not listed inside the PATH. Or some java library files cannot be found, because the classpath points to a wrong location. So just open a command prompt window and show us the output of the commands "echo %PATH%" and "echo %CLASSPATH%". Then please also try to execute "java -version" and show us the output.
          • The source code. It's needed to verify that the class name is always like the file name, and that all include commands are correct. It's a common mistake for beginners to define a class "A" inside their code that calls a class "B", but they put that class "B" into a file named "C.java" and not "B.java", so you will get the error message like above, that the file can not be found.


          So giving us more information would be really helpful in our quest to solve your problem. The more info we get, the less we have to guess, and the faster your problem will be solved.

          Comment

          • lolv007
            New Member
            • Apr 2010
            • 3

            #6
            Oh that's ok, I can imagine it would be frustrating having silly questions like mine. Sorry. I'v tried to include the information you need:
            • Compilation Command: So I tried to compile my file, and this is the entire output:

              NPP_EXEC: "Compile"
              CD: E:\Programming\ Assignment 1 resources\A1Res ources\Stage01
              Current directory: E:\Programming\ Assignment 1 resources\A1Res ources\Stage01
              javac A1Stage01.java
              CreateProcess() failed with error code 2:
              The system cannot find the file specified.

              =============== = READY =============== =



            • The classpath and environmental variables - here is my output from the command prompt:

              C:\Documents and Settings\pbtech >echo %PATH%
              C:\WINDOWS\syst em32;C:\WINDOWS ;C:\WINDOWS\Sys tem32\Wbem;C:Pr ogram Files\Common Files\Roxio Shared\DLLShare d\;C:\Program Files\Java\jdk1 .6.0_14\bin

              C:\Documents and Settings\pbtech >echo %CLASSPATHS%
              %CLASSPATH%

              C:\Documents and Settings\pbtech >java -version
              'java' is not recognised as an internal or external command, operable program or batch file.

            • I'm not too sure about the soruce code - is that my application or program files? I tried attaching them, but it doesn't support java type files. Would it help if I wrote out my program/application on here?


            I think it does have something to do with all of these points (is that possible?).
            Hope that you have the information you requested, thank you so much for your help so far!

            Comment

            • chaarmann
              Recognized Expert Contributor
              • Nov 2007
              • 785

              #7
              You have "C:\Program Files\Java\jdk1 .6.0_14\bin" inside your path. There should be the file "java.exe" (and also "javac.exe" which you need for compilation) inside. But if you try to execute java.exe by calling "java -version" it gives you an error. That means that "java.exe" in not there! Can you please open this folder and see if this folder exists and if yes, if javac.exe is inside? If not, then you must give correct name in PATH (if javac.exe is somewhere else ) or reinstall java (if you cannot find it at all). I bet that's the problem, and after fixing it you will be able to compile in Notepad.

              Second, avoid spaces in your pathname. Even if it works now, you will get problems later on! Put your code in a place that has underscores instead.
              That means to "E:\Programming \Assignment_1_r esources\A1Reso urces\Stage01" (note the underscore before and after "1"!). If you want to stick to Java coding standards, use Camel-Case, name it "Assignment1Res ources".

              Third, can you please give the output of %CLASSPATH% again? You typed an "S" at the end by mistake!

              Instead of listing your source code yet, you can try to compile the code below. Only if the compilation of this source code works, and you still have compilation problems or other problems, you need to post your own code.

              Filename: "Hello.java "
              Compile: "javac Hello.java" (on command prompt)
              Execute: "java Hello" (on command prompt, it should print "Hello World" on command line)
              Code:
              public class Hello 
              { 
                  public static void main (String argv[]) 
                  { 
                      System.out.println("Hello World!"); 
                  } 
              }

              Comment

              • Jynovas
                New Member
                • Mar 2012
                • 1

                #8
                I'm sure you have probably figured this out being as how its 2 years later, but since i didn't see the answer here ill go ahead and explain.

                First you have to install the NppExec plugin in Notepad++. this can be found in the plugin manager. next you have to set your PATH to the jdk. *Note: you HAVE to be using the 32bit JDK as the 64bit version wont work* and yes you can set up the 32bit on a 64 bit system. just install it in the Program Files (x86) directory.

                Next hit the f6 key and copy this into the window that pops up:
                cd $(FULL_CURRENT_ PATH)
                javac $(FILE_NAME)
                java $(NAME_PART)

                hit the save button and and name it something relevant. once its saved hit ok and your program should compile and run in a command window at the bottom of the program.

                Don't worry about CLASSPATH at this point as you're probably not dealing with packages. but again, use the 32 bit version of JDK or this wont work. Also, if you're trying to format your output using "printf" you'll have to compile using windows command prompt because the built in console wont display it properly.

                Hope this helped anyone that might need it.

                Comment

                Working...