4

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)?

oberlies
  • 11,503
  • 4
  • 63
  • 110
  • I just stumbled across [this section on a wiki page](http://wiki.eclipse.org/Tycho/Additional_Tools#tycho-eclipserun-plugin_behind_a_proxy) giving an example of how to generate the preferences file read by `org.eclipse.core.net`. If I can get this working, I'll turn it into an answer here... – oberlies Aug 09 '13 at 15:40
  • [More information on this topic in the Hudson wiki](http://wiki.eclipse.org/Hudson#Configuring_a_proxy_for_the_p2_director) – oberlies Aug 13 '13 at 11:23

4 Answers4

6

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.

Markus Mitterauer
  • 1,560
  • 1
  • 14
  • 28
  • # - Set SOCKS proxy only if neccessary - This line reads: Don't set SOCKS unless you are really sure you need it. Otherwise, even if HTTP/HTTPS is set correctly, it won't work. – Piotr Kepka Jun 15 '22 at 13:43
0

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...

oberlies
  • 11,503
  • 4
  • 63
  • 110
0

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

Community
  • 1
  • 1
Goodwine
  • 1,658
  • 1
  • 18
  • 31
  • You are implying that I should use the native proxy integration. We did this for one project, but this lead to erratic behaviour on Windows, so we decided that we need a more explicit solution. – oberlies Apr 10 '14 at 16:42
  • No, I did not, I didn't even make reference to anything but client/OS versions. I'm trying to say that if you use a x32 Eclipse in a x64 Windows, some settings will not be saved nor loaded. So proxy settings can't be set from "Preferences", and they can't be loaded from the config file either. Switch to the right version for you, and check if the settings are now being successfully saved. – Goodwine Apr 15 '14 at 15:12
  • There are no proxy settings to be loaded. I e.g. have an distribution downloaded from Eclipse, and I want to execute some headless application included in the distribution e.g. on a server. So where should the Eclipse settings applicable for the server come from? – oberlies Apr 15 '14 at 16:24
-1

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)

Enrico
  • 19
  • 2
  • It doesn't work when I set the system property on the command line. What makes you think that setting the system property in the eclipse.ini? – oberlies Apr 10 '14 at 16:44