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

  • Home
  • SEARCH
  • 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 144335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:14:14+00:00 2026-05-11T08:14:14+00:00

I always wondered why I have to manually set the JAVA_HOME environment variable after

  • 0

I always wondered why I have to manually set the JAVA_HOME environment variable after installing the Java SDK.

JAVA_HOME=c:\Program Files\Java\jdk1.6.0_12

Visual Studio at least provides a batch file to set these kind of environment variables:

call ‘c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat’

Does Java have something similar? I’m trying to make a build script that should simply work after installing the Java SDK. I don’t want people to mess with environment variables on their PC.

  • 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. 2026-05-11T08:14:14+00:00Added an answer on May 11, 2026 at 8:14 am

    You can install as many versions of Java as you like.

    It would be dangerous for the setup to modify a local environment variable such as JAVA_HOME, since it might reference an existing Java installation.

    This has nothing to do with an alleged ‘platform dependent issue’. 😉

    Since scripts might depend on JAVA_HOME to launch themselves, again, this would be disasterous for a new Java install to modify JAVA_HOME: all those scripts would suddenly have to be launched with a new potentially incompatible JVM.

    Plus, by setting $JAVA_HOME/bin or %JAVA_HOME%/bin in your path, you can dynamically change JAVA_HOME to whatever version of Java you want to use without having to much with your PATH variable.


    Michael Borgwardt has made in the comments the interesting followup’s question

    Still, this does not explain why the installer does not set JAVA_HOME when it is not previously set at all.

    The answer is simple:

    The setup cannot know if a script already depends on JAVA_HOME or not.

    Meaning: some scripts could test for JAVA_HOME value, and if not set, refer to another JVM installed elsewhere (and do not forget that by ‘install’, one can only refer to ‘copied’: a JDK/JRE is not always installed by a setup)

    If you set JAVA_HOME, that can disrupt the default behavior of some of your scripts.

    Not wanting to disturb hypothetical scripts that depend on a env var not being set sound pointlessly paranoid to me – If a script does that, then it clearly WANTS to use a different JVM when one is installed – no reason to avoid that.

    Mmm… Sweet. For dealing with massive deployment issues on a daily-basis (for internal application in my shop), I can assure you: it is very sane ‘paranoid’ treat to have.
    When you deploy to a (very) large set of users, you do not want to make any assumption about their platform and configurations. ‘clearly WANTS’ is an assumption I would not dare to make (or I redirect my phone to yours 😉 and you handle the angry calls).

    For instance, we have many scripts which launches with a 1.4.2 JVM from sun (JAVA_HOME not set on development platform, default path set directly in the script), or with 1.4.2 from JRockit (JAVA_HOME set, as it is the intended target on integration, pre-production and production platforms).

    But we install regularly the new JDK1.6.x since we use it for launching eclipse.

    Assume that those scripts want their JAVA_HOME set… and nothing works anymore.

    … To which Robert Grant makes this on-the-spot critic:

    You’re describing scripts that require one specific version, but still look at global JAVA_HOME. That’s just badly thought out scripts.

    While that may or may not be true, that also illustrates precisely my point:
    ‘you do not want to make any assumption’: no assumption on their platform/settings, and no assumption on their ‘best practices’.
    The former may sound paranoid, the latter is plain common-sense: thinking that your product (here a JDK setup) will not break anything on the user’s environment because the user has ‘correctly’ thought out his scripts… would be insane.


    GvS suggests:

    Or it could just have option to do it, disabled by default

    That would mean another option to include in the setup screens, option which should be carefully reviewed by the user, and which may have unintended consequences, even when the user selects it thinking he knows what he is doing…

    It is simply not worth it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer If you want to return it in a single query… May 11, 2026 at 3:33 pm
  • added an answer I just figured it out. You can disable MySQL from… May 11, 2026 at 3:33 pm
  • added an answer Without having more detail about what you're doing, it sounds… May 11, 2026 at 3:33 pm

Related Questions

I always wondered why people are still running older web browsers until I started
I always wondered why automatic setting of the pointer to NULL after delete is
I've always wondered why the C++ Standard library has instantiated basic_[io]stream and all its
This may be a matter of style, but there's a bit of a divide

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.