Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:33:25+00:00 2026-06-02T17:33:25+00:00

I want my Java program to use the system’s proxy configuration. Accordingly, I used

  • 0

I want my Java program to use the system’s proxy configuration. Accordingly, I used the code found in many places, such as this answer, to set java.net.useSystemProxies to true and call ProxySelector.getDefault().select(...) to discover the proxy for the particular host I want to reach. This works fine when I’ve configured a single explicit proxy server in Internet Properties. But if I have set “Use automatic configuration script”, it always returns the DIRECT “proxy”.

I know that the script works, as my browser can access the hosts for which it returns a proxy server, and without the script set, it can’t. I even tried simplifying the script to its barest essentials:

function FindProxyForURL(url, host)
{
    return "PROXY my.proxy.mydomain:3128";
}

and it works in my browser, but ProxySelector.getDefault().select(...) still returns only DIRECT.

Am I missing something? (This is on Java 1.6 & Windows 7, should it matter.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:33:26+00:00Added an answer on June 2, 2026 at 5:33 pm

    No, the Java ProxySelector does not read Proxy Auto-Config (PAC) files.

    However, as suggested by Brian de Alwis as an answer to my similar question, the Proxy Vole library appears to provide that support/capability.

    To provide network connectivity out of the box for you Java
    application you can use the Proxy – Vole library. It provides some
    strategies for autodetecting the current proxy settings. There are
    many configureable strategies to choose from. At the moment Proxy –
    Vole supports the following proxy detection strategies.

    • Read platform settings (Supports: Windows, KDE, Gnome, OSX)
    • Read browser setting (Supports: Firefox 3.x, Internet Explorer; Chrome and Webkit use the platform settings)
    • Read environment variables (often used variables on Linux / Unix server systems)
    • Autodetection script by using WPAD/PAC (Not all variations supported)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the java.util.Preferences API but I don't want my program to
I want to use system commands like mkdir and rmdir while running a java
How can I detect endianness on a system in java?I dont want to use
I want to use JRAT profiler for my simple java program which is as
I want to use a linux command line tool from my Java program. I
I want to write a java program that acts as a user interface to
From within my Java program I want to determine which .NET Framework is installed
I want to create registry key through java program to add the jar file
I want to start my successfully installed Java program after the installation finished. I
In a Java program, I have a list of beans that I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.