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 4618596
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:23+00:00 2026-05-22T02:17:23+00:00

In Ubuntu, I’d like to switch my JAVA_HOME environment variable back and forth between

  • 0

In Ubuntu, I’d like to switch my JAVA_HOME environment variable back and forth between Java 5 and 6.

I open a terminal and type in the following to set the JAVA_HOME environment variable:

export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun

And in that same terminal window, I type the following to check that the environment variable has been updated:

echo $JAVA_HOME

And I see /usr/lib/jvm/java-1.5.0-sun which is what I’m expecting to see. In addition, I modify ~/.profile and set the JAVA_HOME environment variable to /usr/lib/jvm/java-1.5.0-sun.

And now for the problem–when I open a new terminal window and I check my JAVA_HOME environment variable by typing in echo $JAVA_HOME I see that my JAVA_HOME environment variable has been reverted back to Java 6. When I reboot my machine (or log out and back in, I suppose) the JAVA_HOME environment variable is set to Java 5 (presumably because of the modification I made in my ~/.profile).

Is there a way around this so that I can change my JAVA_HOME environment without having to log out and back in (AND make that environment variable change stick in all new terminal windows)?

  • 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-05-22T02:17:24+00:00Added an answer on May 22, 2026 at 2:17 am

    Put the environment variables into the global /etc/environment file:

    ...
    export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
    ...
    

    Execute “source /etc/environment” in every shell where you want the variables to be updated:

    $ source /etc/environment
    

    Check that it works:

    $ echo $JAVA_HOME
    $ /usr/lib/jvm/java-1.5.0-sun
    

    Great, no logout needed.

    If you want to set JAVA_HOME environment variable in only the terminal, set it in ~/.bashrc file.

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

Sidebar

Related Questions

The Ubuntu startup/login sound can be very loud, but I do like having it.
I'm accessing an Ubuntu machine using PuTTY, and using gcc. The default LANG environment
Ubuntu 9.10 / CentOS 5.5 PHP 5.2.10-2ubuntu6.7 / 5.2.11 The following minimal testcase gives
Ubuntu has 8 run levels (0-6 and S), I want to add the run
My Ubuntu server has Apache and Subversion installed. I use this server as a
I'm on laptop (Ubuntu) with a network that use HTTP proxy (only http connections
I'm deploying to Ubuntu slice on slicehost, using Rails 2.1.0 (from gem ) If
I've installed Ubuntu Server (8.04) into Parallels and found that the system time/clock ran
I'm using an Ubuntu 8.04 (x86_64) machine to connect to my employer's Cisco VPN.
kt@rails-ubuntu:~/rails/ledger/releases/20080820144914/.git/hooks$ ls -al ls: cannot access post-commit: No such file or directory ls: cannot

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.