Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4522

"Run file" does not handle path with spaces correctly (on Windows)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.0
    • None
    • java - Compiler
    • None
    • NetBeans 12.0
      AdoptOpenJDK (build 11.0.7+10) and AdoptOpenJDK (build 13.0.2+8)
      Window 10 1809

    Description

      If I want to run a Sourcefile within the IDE with JDK11+ and the path for the file has spaces the file can not be executed

       

      Steps (in windows cmd.exe):

      C:\>md "Path with space"

      C:\>cd Path with space

      C:\Path with space>copy con SampleClass.java
      public class SampleClass{
      public static void main(String[] args){
      System.out.println("Sample");
      }}^Z
      1 Datei(en) kopiert.

      C:\Path with space>java SampleClass.java
      Sample

      C:\Path with space>java %CD%\SampleClass.java
      Fehler: Hauptklasse C:\Path konnte nicht gefunden oder geladen werden
      Ursache: java.lang.ClassNotFoundException: C:\Path

      C:\Path with space>java "%CD%\SampleClass.java"
      Sample

      C:\Path with space>java "%CD:\=/%/SampleClass.java"
      Sample

      C:\Path with space>java %CD:\=/%/SampleClass.java
      Fehler: Hauptklasse C:.Path konnte nicht gefunden oder geladen werden
      Ursache: java.lang.ClassNotFoundException: C:.Path

      C:\Path with space>java -Duser.language=en %CD:\=/%/SampleClass.java
      Error: Could not find or load main class C:.Path
      Caused by: java.lang.ClassNotFoundException: C:.Path

       

      the exact same error message () as the last command is shown if I open this file in NetBeans and call "Run file" from the context menu. So it seems the generate "command line" to execute the file is missing some quotes.

      Attachments

        Activity

          People

            Unassigned Unassigned
            nigjo Jens Hofschröer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: