I apologize if this is a silly question, but I don...
# java-and-jvm
b
I apologize if this is a silly question, but I don’t know much about using Java and I’m trying to use some java.net.http classes (bug with cfhttp file posting, long story) and it’s throwing an error. Code:
Copy code
<cfscript>
    target = "<http://127.0.0.1:51943/test-accept-file.cfm>";

    httpClientObj = new java("java.net.http.HttpClient");
    httpRequestObj = new java("java.net.http.HttpRequest");
    uriObj = new java("java.net.URI");

    client = httpClientObj.newHttpClient();
    request = httpRequestObj.newBuilder()
        .uri((uriObj.create(javaCast("string", target))))
        .header("accept", "application.json")
        .build();
</cfscript>
Error:
java.lang.reflect.InaccessibleObjectException: Unable to make public jdk.internal.net.http.HttpRequestBuilderImpl(java.net.URI) accessible: module java.net.http does not “exports jdk.internal.net.http” to unnamed module @a68df9
I don’t understand why java.net.URI is not accessible, isn’t it public?