I'm trying to open an http socket in an annotation processor on Windows, and am getting the following stacktrace:
java.net.SocketException: Unrecognized Windows Sockets error: 10106: create
at java.net.Socket.createImpl(Socket.java:397)
at java.net.Socket.connect(Socket.java:527)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
...
I have looked into the error a little and it seems it may be because the annotation processor (run though javac) has no access to environment variables such as SystemRoot. I tested this by calling System.getenv("SystemRoot")
from my annotation processor and it returned null. In normal code it returned C:\Windows
as expected.
Is there any way to pass environment variables into javac? Or even set them programmatically although I suspect that's evil.