I tried the following code:
<code>import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
public class demo {
public static void main(String[] args) throws IOException, InterruptedException {
try {
System.out.println(Paths.get(new URI("C:\Windows")).toFile().getAbsolutePath());
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
</code>
<code>import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
public class demo {
public static void main(String[] args) throws IOException, InterruptedException {
try {
System.out.println(Paths.get(new URI("C:\Windows")).toFile().getAbsolutePath());
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
</code>
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
public class demo {
public static void main(String[] args) throws IOException, InterruptedException {
try {
System.out.println(Paths.get(new URI("C:\Windows")).toFile().getAbsolutePath());
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
Exception in eclipse
<code>java.net.URISyntaxException: Illegal character in opaque part at index 2: C:Windows
at java.base/java.net.URI$Parser.fail(URI.java:2995)
at java.base/java.net.URI$Parser.checkChars(URI.java:3166)
at java.base/java.net.URI$Parser.parse(URI.java:3202)
at java.base/java.net.URI.<init>(URI.java:645)
at tt/demo.demo.main(demo.java:11)
</code>
<code>java.net.URISyntaxException: Illegal character in opaque part at index 2: C:Windows
at java.base/java.net.URI$Parser.fail(URI.java:2995)
at java.base/java.net.URI$Parser.checkChars(URI.java:3166)
at java.base/java.net.URI$Parser.parse(URI.java:3202)
at java.base/java.net.URI.<init>(URI.java:645)
at tt/demo.demo.main(demo.java:11)
</code>
java.net.URISyntaxException: Illegal character in opaque part at index 2: C:Windows
at java.base/java.net.URI$Parser.fail(URI.java:2995)
at java.base/java.net.URI$Parser.checkChars(URI.java:3166)
at java.base/java.net.URI$Parser.parse(URI.java:3202)
at java.base/java.net.URI.<init>(URI.java:645)
at tt/demo.demo.main(demo.java:11)
I’m trying to make a gradle plugin that contains this piece of code.
I execute it in Gradle and he works, why does he get this exception in Eclipse?
New contributor
user25459605 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.