EDR
EDR

Reputation: 277

java.nio.file.InvalidPathException: Illegal char <:> when using Paths.get()

When I use Paths.get() to create a directory I encounter exception below.

java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/Desktop/workspaces/sra/emm-be/wsm-kap-api-server/target/test-classes/swagger\swagger.json

This happens when I use the workspace of my Windows machine. For linux, it's working fine.

Upvotes: 9

Views: 23317

Answers (2)

Filip Hartman
Filip Hartman

Reputation: 41

You have / before C in Your directory path. If you remove it it should work on Windows too.

 Paths.get(C:/Users/Desktop/workspaces/sra/emm-be/wsm-kap-api-server/target/test-classes/swagger/swagger.json);

Upvotes: 4

SamHoque
SamHoque

Reputation: 3154

Your directory path contains / try using

    Paths.get("C:\\Users\\Desktop\\workspaces\\sra\\emm-be\\wsm-kap-api-server\\target\\test-classes\\swagger\\swagger.json");

Upvotes: 4

Related Questions