Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355360

-d option of jwebserver command should accept relative paths

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      openjdk 25-ea 2025-09-16
      OpenJDK Runtime Environment (build 25-ea+19-2255)
      OpenJDK 64-Bit Server VM (build 25-ea+19-2255, mixed mode, sharing)

      PRETTY_NAME="Ubuntu 24.04.2 LTS"
      NAME="Ubuntu"
      VERSION_ID="24.04"
      VERSION="24.04.2 LTS (Noble Numbat)"
      VERSION_CODENAME=noble
      ID=ubuntu
      ID_LIKE=debian
      HOME_URL="https://www.ubuntu.com/"
      SUPPORT_URL="https://help.ubuntu.com/"
      BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
      PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
      UBUNTU_CODENAME=noble
      LOGO=ubuntu-logo

      5.15.167.4-microsoft-standard-WSL2 (Windows 11 WSL)

      ---

      openjdk 21.0.3 2024-04-16 LTS
      OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
      OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

      Windows 11

      A DESCRIPTION OF THE PROBLEM :
      Currently, the -d option of jwebserver does not accept relative paths.

      ```
      $ jwebserver -d build
      Error: server config failed: Path is not absolute: build
      ```

      However, this is not convenient or friendly because most other CLI commands accept relative paths as arguments and the workaround is not cross-platform or can leak your personal information. You have to choose the appropriate option from the following to get the current directory:

      Windows + CMD (e.g. Node.js npm scripts): %cd%
      Windows + PowerShell / non-Windows: $PWD

      For example, if you want to use jwebserver in package.json (Node.js) without additional dependencies, Windows users will be discriminated if you write:

      ```json
      {
        "scripts":
          "dev": "some-command",
          "build": "some-command",
          "serve", "jwebserver -d $PWD/build"
        }
      }
      ```

      If you replace `$PWD` with your user name, your privacy information will be exposed and this script cannot used by the other people. If you replace `$PWD/` with `%cd%\`, non-Windows users cannot run `node --run serve`.

      I will submit this report as a bug because there is no specific stipulation that jwebserver must accept only absolute paths as -d option in the text of JEP-408 or JDK-8245095. If you think this "behavior" is stipulated in the JEP, you can convert this report to a feature.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      mkdir build
      jwebserver -d build

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Binding to loopback by default. For all interfaces use "-b 0.0.0.0" or "-b ::".
      Serving /home/directory_of_you/build and subdirectories on 127.0.0.1 port 8000
      URL http://127.0.0.1:8000/
      ACTUAL -
      Error: server config failed: Path is not absolute: build

            vyazici Volkan Yazici
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: