Home > Back-end >  java.nio.file.InvalidPathException: Illegal char <"> at index 0: "C:\Program Files
java.nio.file.InvalidPathException: Illegal char <"> at index 0: "C:\Program Files

Time:12-10

I want to compile a Quarkus project to native on my Windows 10 Home 64-bit computer, using the following command:

.\mvnw package -Pnative

The computer has GraalVM 21.3.0 installed, with GRAALVM_HOME, JAVA_HOME and PATH all set accordingly. Native-image is installed. It also runs Docker via WSL2. In theory, all should be set. Instead I get this error, using a basic project with only a few extensions installed. Project uses Maven as package manager.

Fatal error:java.nio.file.InvalidPathException: Illegal char <"> at index 0: "C:\Program Files\Git\bin\\cl.exe
        at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
        at java.base/java.nio.file.Path.of(Path.java:147)
        at java.base/java.nio.file.Paths.get(Paths.java:69)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.lambda$lookupSearchPath$1(CCompilerInvoker.java:497)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.lookupSearchPath(CCompilerInvoker.java:499)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.getCCompilerPath(CCompilerInvoker.java:509)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.getCCompilerInfo(CCompilerInvoker.java:356)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.<init>(CCompilerInvoker.java:70)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker$WindowsCCompilerInvoker.<init>(CCompilerInvoker.java:110)
        at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.create(CCompilerInvoker.java:84)
        at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:864)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:527)
        at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:488)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:569)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:122)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:599)

Things I have tried to far is to check the PATH environment variable, specifically the one going to the Git directory, and also tried searching through the project search tree in IntelliJ, with no luck. It seems like it would be very easy to solve, if I can find where the problem lies. Any ideas?

Thanks in advance!

CodePudding user response:

As so many times before this, the error messages I get by the terminal tend not to be very helpful.

When I originally tried to do native compilation, I had watched a guide where the instructor used Mac as his default development environment.

There is an extra step for Windows, which is descibed here: enter image description here

Basically, I needed to install Visual Studio 2022 with the Windows 10 SDK. I had a version of Visual Studio 2017 installed, but a patch too low and I lacked disk space to simply update that one on its install location on the C: drive.

After installing, I had to open x64 Native Tools command prompt (Start > Visual Studio 2022 > x64 Native Tools command prompt). The command won't work in the regular Powershell or CMD. Compilation was only successful after restarting my computer - before that I ended up with error c1083.

Now I have a 51 MB executable.

  • Related