Question

I have a script which needs to call one of the existing, headless Eclipse applications (example: the p2 director application) which use the Proxy API of org.eclipse.core.net for configuring its requests to HTTP servers.

On Linux, I can configure the Eclipse Proxy API by setting the environment variables http_proxy and https_proxy.

Is there similar solution for configuring the proxies from the command line in Windows?


I've tried to set HTTP proxy configuration properties specified by Java (http.proxyHost, http.proxyPort, etc.) but this doesn't work. Setting the properties just results in a log entry from Eclipse informing me that the system properties are overwritten with the values from the preferences:

!ENTRY org.eclipse.core.net 1 0 2013-08-09 15:21:19.413
!MESSAGE System property http.proxyHost has been set to proxy by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2013-08-09 15:21:19.414
!MESSAGE System property http.proxyPort has been set to 8080 by an external source. This value will be overwritten using the values from the preferences

So another option would be a headless application which allows to configure preferences. Does this application exist (preferrably as part of the standard Eclipse distributions)?

Was it helpful?

Solution

Proxy preferences for Eclipse applications are stored in the file

<eclipse-installation>/configuration/.settings/org.eclipse.core.net.prefs

So either you edit the settings via the Eclipse preferences UI (General / Network Connections) and then copy that file to your headless application, or you create/edit that manually:

eclipse.preferences.version=1
nonProxiedHosts=localhost|127.0.0.1
org.eclipse.core.net.hasMigrated=true
proxiesEnabled=true
proxyData/HTTP/hasAuth=false
proxyData/HTTP/host=<proxy.your.org>
proxyData/HTTP/port=<port>
proxyData/HTTPS/hasAuth=false
proxyData/HTTPS/host=<proxy.your.org>
proxyData/HTTPS/port=<port>
# - Set SOCKS proxy only if neccessary -
# proxyData/SOCKS/hasAuth=false
# proxyData/SOCKS/host=<proxy.your.org>
# proxyData/SOCKS/port=<port>
systemProxiesEnabled=false

HTH.

OTHER TIPS

From what I could find out, it seems that setting the proxy from the command line is not possible in Windows – but I really hope that someone else has a better answer.

There was a bug report for the fact that Eclipse ignores the Java proxy configuration (bug 298813). This bug even included a patch, but unfortunately it was abandoned for a "more general solution" (bug 257443). That bug was originally planned for Eclipse 3.5, but up to now was never completed.

So this doesn't look good...

I was facing the same problem, and I tried different solutions mentioned here and in several blogs without having one working to me.

However... one solution I found is that if you have an x32 Eclipse IDE, and an x64 OS, setting will not always save, and you may face these problems.

I had this problem with Juno x32 + Win7 x64, now it's solved using Juno x64, and Kepler x64

So, check your OS/IDE and make sure that you have the right versions.

It may be the same problem as this question

Try to put the same properties (http.proxyHost and http.proxyPort) inside the eclipse.ini file into -vmargs section using -d (-Dhttp.proxyHost=htttp://yourproxy and -Dhttp.proxyPort=port)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top