• Login
Community
  • Login

How to run Java applications in Notebook++ version 7.9

Scheduled Pinned Locked Moved General Discussion
8 Posts 4 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    Dhamnekar Winod
    last edited by Aug 17, 2021, 3:02 PM

    I want to run SimpleCalc.java in Notpad++ ,but it showed error. I have run SimpleCalculator.java under NetbeansProjects directory successfully. How to debug this running java application process?
    3d6db83c-341b-4cd5-a40a-2b8757d18dab-image.png

    P 1 Reply Last reply Aug 17, 2021, 3:16 PM Reply Quote 0
    • P
      PeterJones @Dhamnekar Winod
      last edited by PeterJones Aug 17, 2021, 3:16 PM Aug 17, 2021, 3:16 PM

      @Vinod-Dhamnekar ,

      We cannot be expected to be Java experts and thus debug any Java problems you might be having – as a forum for a text editor, doing programming debugging is off topic.

      From the Notepad++ standpoint, it appears you are using the NppExec to run javac on the active file. It’s using the command javac SimpleCalc.java to call that. If you were at a normal command prompt (cmd.exe or powershell), would that command be sufficient? Do you know what command-line that NetbeansProjects uses when calling your SimpleCalc.java ?

      I haven’t done any java recently, but a few years ago, I played around with it some. At that time, I had created a java-compile and java-compile-and-run script for NppExec:

      compile:

      NPP_SAVE
      cd "$(CURRENT_DIRECTORY)"
      javac "$(FILE_NAME)"
      

      compile then run

      NPP_SAVE
      cd "$(CURRENT_DIRECTORY)"
      javac "$(FILE_NAME)"
      java -classpath "$(CURRENT_DIRECTORY)" "$(NAME_PART)"
      

      You will notice that I do slightly more than just run javac: first I make sure the file is saved (otherwise javac will see the last-saved version, which might not match what I have open in Notepad++ if I’ve forgotten to save first); second, I change into the same directory that the .java file is saved in (NppExec doesn’t guarantee it will set up its environment in the same folder); then third, I use javac to compile the .java source code.

      Also, looking briefly at your error message in the console, it says “class SimpleCalculator is public, should be declared in a file named SimpleCalculator.java”, but your file is called SimpleCalc.java . I don’t remember enough of my java to be sure, but a quick google told me that “the public class name must match the file name. Inner, non public, class names may differ.” – this strongly tells me that you should rename the file SimpleCalculator.java. Notice, you even say,

      I want to run SimpleCalc.java in Notepad++ ,but it showed error. I have run SimpleCalculator.java under NetbeansProjects directory successfully.

      You said that you have the file called SimpleCalc.java in Notepad++, but you had a file called SimpleCalculator.java when you ran it under Netbeans. That lends strength to the suggestion that you should try running it with the filename and the public class name matching.

      If you have more questions that are specific to Notepad++ and NppExec, feel free to ask follow ups.

      D 1 Reply Last reply Aug 17, 2021, 3:54 PM Reply Quote 3
      • D
        Dhamnekar Winod @PeterJones
        last edited by Aug 17, 2021, 3:54 PM

        @PeterJones As per your suggestion, I renamed the file to SimpleCalculator.java.
        Please tell me in NppExec\execute window, are there any errors in writing command syntax? See the following picture.

        5432406b-af9f-42a5-b46f-a28929d717e3-image.png
        with regards,
        WMD

        P 1 Reply Last reply Aug 17, 2021, 3:58 PM Reply Quote 0
        • P
          PeterJones @Dhamnekar Winod
          last edited by PeterJones Aug 17, 2021, 4:01 PM Aug 17, 2021, 3:58 PM

          @Vinod-Dhamnekar ,

          I gave you the literal contents of the script. You did not need to manually put in the values.

          6ffb6714-7bfe-4b05-a22d-57897443929c-image.png

          D 2 Replies Last reply Aug 18, 2021, 4:27 AM Reply Quote 1
          • M
            mere-human
            last edited by Aug 17, 2021, 4:17 PM

            I actually like this name “Notebook++”. It looks fresh!
            Sorry for off-topic.😀

            1 Reply Last reply Reply Quote 2
            • D
              Dhamnekar Winod @PeterJones
              last edited by Aug 18, 2021, 4:27 AM

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • D
                Dhamnekar Winod @PeterJones
                last edited by Aug 18, 2021, 11:43 AM

                @PeterJones I successfully implemented the SimpleCalculator java program( by moving its locations to Documents folder) under NppExec plugin and obtained the desired result in Notepad++
                With regards,
                WMD

                1 Reply Last reply Reply Quote 0
                • D
                  dominikcebula
                  last edited by Feb 26, 2025, 9:27 PM

                  You can also consider using “Java Plugin for Notepad++”:
                  https://dominikcebula.github.io/npp-java-plugin/

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors