Run jar java version

Changing current version of Java within Windows

I’m working in a Windows XP environment and have recently installed java 1.6 because it was required by an application. However I don’t want this to be the default version of java to be used. How do I set it so that the command java -version will return 1.5.x

I would take a look at path environment variable. You can examine it in command line with: echo %PATH% . These are default folders where binaries are looked for. If you find a path to JAVA you could adjust it easily in System Preferences.

7 Answers 7

Change your PATH variable so that it has the location of the jdk5/bin directory:

  1. Start -> Control Panel -> System -> Advanced
  2. Click on Environment Variables, under System Variables, find PATH, and click on it.
  3. In the Edit windows, modify PATH by adding the location of your jdk5/bin directory to the beginning. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the directory as the value.
  4. Close the window.
  5. Reopen Command prompt window, and run java -version
Читайте также:  Php buffer to string

That’s because when you install Java, the bins are put into C:\WINDOWS\system32, which is part of your PATH. You should add the jre/bin directory to the beginning of the PATH.

If you have multiple JREs installed, the only way to achieve this is by changing the registry entry. Especially because there are tools which read the JRE info from registry and not the class path.

set JAVA_HOME=C:\jdk1.6.0u24 set PATH=%JAVA_HOME%\bin;%PATH% 

That will temporarily set up the environment in the command shell. Maven, Ant, etc. will pick up on your new version of Java without having to go to the Control Panel repeatedly.

Tools like Eclipse should be able to select which JDK to use in their own configuration tools for use within their environments.

Java 8 creates three shortcuts on \ProgramData\Oracle\Java\javapath that point to the latest Java8 java.exe, javaw.exe and javaws.exe and then puts \ProgramData\Oracle\Java\javapath at the front of the PATH so that no matter what you do to the JAVA_PATH environment variable, you still get the latest Java 8.

You can get around this by

1) renaming \ProgramData\Oracle\Java\javapath to something else (\ProgramData\Oracle\Java\javapath8 for example)

2) creating a new javapath folder under Java and

3) creating the shortcuts that you need.

Just restore the javapath when you are done with the old versions and you get Java 8 back.

Short, but to the point, very good answer, this one explains more specifically how to generate multiple versions of javapath folders, using symbolic links, so you could switch with no time between versions, and the registry stuff that is missing here, screenshots and trick to avoid reboot after changes too. see stackoverflow.com/questions/27996603.

There are two ways to fix this:

1) Change the PATH (as someone has already mentioned) The important thing with this solution is to set JAVA_HOME before the windows paths. This is because under the windows folder, there is a java.exe that redirects to the last installed jre.

2) Regedit. The key HKEY_LOCAL_MACHINE->SOFTWARE->JAVASOFT->Java Runtime Environment contains the last installed version that the java.exe in the windows folder redirects to. If you change this to a previously installed version, everything should be peachy. (At least, I think this is the right registry key)

Источник

Thread: How to run JAR file with different version of java

ngubk is offlineA Carafe of Ubuntu

Join Date Dec 2010 Location Hanoi — Vietnam Beans 109 —> Beans 109 Distro Ubuntu 12.04 Precise Pangolin

How to run JAR file with different version of java

I downloaded jdk and jre1.5.0_16 and compile my project(this one is quite old so it had some error with the newest version) in Eclipse fine. But my default JDK is still 1.6

ngu@MyUbuntu:~/workspace/ims-communicator$ java -version java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.9) (6b20-1.9.9-0ubuntu1~10.10.2) OpenJDK Server VM (build 19.0-b09, mixed mode)

Anyone wants to be friends with a Vietnamese? Here’s my skype name: dangtranngu89 and my gmail: ngu.dangtran. My hobbies are new techs, manga and Ubuntu.

cavh is offlineWay Too Much Ubuntu

Join Date Nov 2007 Location Surrey, England Beans 259 —> Beans 259 Distro Ubuntu 11.04 Natty Narwhal

Re: How to run JAR file with different version of java

In a terminal, navigate to the directory containing the java 1.5 executable

and run your command from there.

Alternatively you can set 1.5 as your default Java installation by running

sudo update-alternatives --config java

Friend of eclipse — http://www.eclipse.org/donate/
Read man pages the easy way — http://manpages.ubuntu.com

ngubk is offlineA Carafe of Ubuntu

Join Date Dec 2010 Location Hanoi — Vietnam Beans 109 —> Beans 109 Distro Ubuntu 12.04 Precise Pangolin

Re: How to run JAR file with different version of java

ngu@MyUbuntu:~$ sudo update-alternatives --config java [sudo] password for ngu: There is only one alternative in link group java: /usr/lib/jvm/java-6-openjdk/jre/bin/java Nothing to configure.

Anyone wants to be friends with a Vietnamese? Here’s my skype name: dangtranngu89 and my gmail: ngu.dangtran. My hobbies are new techs, manga and Ubuntu.

ngubk is offlineA Carafe of Ubuntu

Join Date Dec 2010 Location Hanoi — Vietnam Beans 109 —> Beans 109 Distro Ubuntu 12.04 Precise Pangolin

Re: How to run JAR file with different version of java

ngu@MyUbuntu:/usr/lib/jvm/jdk1.5.0_16/bin$ ./java -jar /home/ngu/workspace/ims-communicator/ims-communicator.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/NoProcessorException at net.java.sip.communicator.SipCommunicator.(SipCommunicator.java:126) at net.java.sip.communicator.SipCommunicator.main(SipCommunicator.java:423)

I think it relates to JMF. Do you have any idea how to fix this? I have already done a lot of search but nothing seems helpfull.

Anyone wants to be friends with a Vietnamese? Here’s my skype name: dangtranngu89 and my gmail: ngu.dangtran. My hobbies are new techs, manga and Ubuntu.

ngubk is offlineA Carafe of Ubuntu

Join Date Dec 2010 Location Hanoi — Vietnam Beans 109 —> Beans 109 Distro Ubuntu 12.04 Precise Pangolin

Re: How to run JAR file with different version of java

Do you know how to change CLASSPATH and LIBRARY_PATH and other necessary stuffs for JMF. I’ve downloaded JMF from SUN website

Anyone wants to be friends with a Vietnamese? Here’s my skype name: dangtranngu89 and my gmail: ngu.dangtran. My hobbies are new techs, manga and Ubuntu.

Azdour is offlineQuad Shot of Ubuntu

Re: How to run JAR file with different version of java

I’m guessing you did not install the Sun JDK 1.5 via Synaptic Package Manager or apt-get.. so Ubuntu will not know about it.

Here you will find instructions on how to add different Java version to Ubuntu so that you can switch to them via the alternative command:

ngubk is offlineA Carafe of Ubuntu

Join Date Dec 2010 Location Hanoi — Vietnam Beans 109 —> Beans 109 Distro Ubuntu 12.04 Precise Pangolin

Re: How to run JAR file with different version of java

QuoteOriginally Posted by Azdour View Post

I’m guessing you did not install the Sun JDK 1.5 via Synaptic Package Manager or apt-get.. so Ubuntu will not know about it.

Here you will find instructions on how to add different Java version to Ubuntu so that you can switch to them via the alternative command:

Anyone wants to be friends with a Vietnamese? Here’s my skype name: dangtranngu89 and my gmail: ngu.dangtran. My hobbies are new techs, manga and Ubuntu.

cavh is offlineWay Too Much Ubuntu

Join Date Nov 2007 Location Surrey, England Beans 259 —> Beans 259 Distro Ubuntu 11.04 Natty Narwhal

Re: How to run JAR file with different version of java

Azdour is correct, you cannot simply copy jdk1.5.0_16 into usr/lib/jvm, that’s not the way to do it. Read the help.ubuntu.com link I gave in my initial post for the way to install Java correctly. Once you have it correctly installed, you can follow either of the two options I gave.

Friend of eclipse — http://www.eclipse.org/donate/
Read man pages the easy way — http://manpages.ubuntu.com

  • Site Areas
  • Settings
  • Private Messages
  • Subscriptions
  • Who’s Online
  • Search Forums
  • Forums Home
  • Forums
  • The Ubuntu Forum Community
    1. Ubuntu Official Flavours Support
      1. New to Ubuntu
      2. General Help
      3. Installation & Upgrades
      4. Hardware
      5. Desktop Environments
      6. Networking & Wireless
      7. Multimedia Software
    2. Ubuntu Specialised Support
      1. Ubuntu Development Version
      2. Security
      3. Virtualisation
      4. Ubuntu Servers, Cloud and Juju
        1. Server Platforms
        2. Ubuntu Cloud and Juju
      5. Gaming & Leisure
        1. Emulators
      6. Wine
      7. Development & Programming
        1. Packaging and Compiling Programs
        2. Development CD/DVD Image Testing
        3. Ubuntu Application Development
        4. Ubuntu Dev Link Forum
        5. Programming Talk
        6. Repositories & Backports
          1. Ubuntu Backports
            1. Bug Reports / Support
      8. System76 Support
      9. Apple Hardware Users
    3. Ubuntu Community Discussions
      1. Ubuntu, Linux and OS Chat
        1. Recurring Discussions
        2. Full Circle Magazine
      2. The Cafe
        1. Cafe Games
      3. Market
      4. Mobile Technology Discussions (CLOSED)
      5. Announcements & News
      6. Weekly Newsletter
      7. Membership Applications
      8. The Fridge Discussions
      9. Forum Council Agenda
      10. Forum Feedback & Help
        1. Request a LoCo forum
      11. Resolution Centre
    4. Other Discussion and Support
      1. Other OS Support and Projects
        1. Other Operating Systems
          1. Ubuntu/Debian BASED
          2. Debian
          3. MINT
          4. Arch and derivatives
          5. Fedora/RedHat and derivatives
          6. Mandriva/Mageia
          7. Slackware and derivatives
          8. openSUSE and SUSE Linux Enterprise
          9. Mac OSX
          10. PCLinuxOS
          11. Gentoo and derivatives
          12. Windows
          13. BSD
          14. Any Other OS
      2. Assistive Technology & Accessibility
      3. Art & Design
      4. Education & Science
      5. Documentation and Community Wiki Discussions
      6. Tutorials
        1. Outdated Tutorials & Tips
      7. Ubuntu Women
      8. Ubuntu LoCo Team Forums
        1. Americas LoCo Teams
          1. Argentina Team
            1. Software
            2. Hardware
            3. Comunidad
          2. Arizona Team — US
          3. Arkansas Team — US
          4. Brazil Team
          5. California Team — US
          6. Canada Team
          7. Centroamerica Team
          8. Chile Team
            1. Comunidad
            2. Hardware
            3. Software
            4. Instalaci�n y Actualizaci�n
          9. Colombia Team — Colombia
          10. Georgia Team — US
          11. Illinois Team
          12. Indiana — US
          13. Kentucky Team — US
          14. Maine Team — US
          15. Minnesota Team — US
          16. Mississippi Team — US
          17. Nebraska Team — US
          18. New Mexico Team — US
          19. New York — US
          20. North Carolina Team — US
          21. Ohio Team — US
          22. Oklahoma Team — US
          23. Oregon Team — US
          24. Pennsylvania Team — US
          25. Peru Team
          26. Texas Team — US
          27. Uruguay Team
          28. Utah Team — US
          29. Virginia Team — US
          30. West Virginia Team — US
        2. Asia and Oceania LoCo Teams
          1. Australia Team
          2. Bangladesh Team
          3. Hong Kong Team
          4. Myanmar Team
          5. Philippine Team
          6. Singapore Team
        3. Europe, Middle East, and African (EMEA) LoCo Teams
          1. Albania Team
          2. Catalan Team
          3. Portugal Team
          4. Egypt Team
          5. Georgia Team
          6. Ireland Team — Ireland
          7. Kenyan Team — Kenya
          8. Kurdish Team — Kurdistan
          9. Lebanon Team
          10. Morocco Team
          11. Saudi Arabia Team
          12. Sudan Team
          13. Tunisia Team
        4. Other Forums & Teams
        5. LoCo Archive
          1. Afghanistan Team
          2. Alabama Team — US
          3. Alaska Team — US
          4. Algerian Team
          5. Andhra Pradesh Team — India
          6. Austria Team
          7. Bangalore Team
          8. Bolivia Team
          9. Cameroon Team
          10. Colorado Team — US
          11. Connecticut Team
          12. Costa Rica Team
          13. Delhi Team
          14. Ecuador Team
          15. El Salvador Team
          16. Florida Team — US
          17. Galician LoCo Team
          18. Greek team
          19. Hawaii Team — US
          20. Honduras Team
          21. Idaho Team — US
          22. Iowa Team — US
          23. Jordan Team
          24. Kansas Team — US
          25. Libya Team
          26. Louisiana Team — US
          27. Maryland Team — US
          28. Massachusetts Team
          29. Michigan Team — US
          30. Missouri Team — US
          31. Montana Team — US
          32. Namibia Team
          33. Nevada Team — US
          34. New Hampshire Team — US
          35. New Jersey Team — US
          36. Northeastern Team — US
          37. Panama Team
          38. Paraguay Team
          39. Qatar Team
          40. Quebec Team
          41. Rhode Island Team — US
          42. Senegal Team
          43. South Carolina Team — US
          44. South Dakota Team — US
          45. Switzerland Team
          46. Tamil Team — India
          47. Tennessee Team — US
          48. Trinidad & Tobago Team
          49. Uganda Team
          50. United Kingdom Team
          51. US LoCo Teams
          52. Venezuela Team
          53. Wales Team
          54. Washington DC Team — US
          55. Washington State Team — US
          56. Wisconsin Team
          57. Yemen Team
          58. Za Team — South Africa
          59. Zimbabwe Team

Источник

Оцените статью