Skip to main content
xenoveritas.org

Main navigation

  • Categories
  • Home
  • Links
  • Name Generator
  • Scramble
User account menu
  • Log in

Breadcrumb

  1. Home

Converting the http_proxy environment variable to Java settings via script

By Xenoveritas, 19 January, 2010
Topics
Linux
Java
  • Add new comment

Since this involves some shell parameter expansion magic, here is a very simple script for copying the "http_proxy" environment variable to the Java proxy properties:

if [ -n "$http_proxy" ]; then
  # http_proxy should be something like http://host:port
  # trim the "http://" off:
  local host="${http_proxy#http://}"
  # trim the host part off:
  local port="${host#*:}"
  # The final substitution removes the port for the host,
  # and removes any (erroneously) appended junk to the port.
  JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=${host%:*}\
    -Dhttp.proxyPort=${port%/*}"
fi

The JAVA_OPTS variable will now have the proxy settings appended to it.

Current Games

I'm currently playing:

  • Final Fantasy XIV: Endwalker

I intend to maybe get around to finishing:

  • Literally anything else

Video Games Section

Thought for the Moment

I never have thoughts any more.

Old Thoughts

Has the LHC Destroyed the Earth?

  • Create new account
  • Reset your password
RSS feed
Powered by Drupal