Set java home windows path

Содержание
  1. Как прописать JAVA_HOME?
  2. Windows:
  3. Ubuntu:
  4. JRE_HOME
  5. How to set JAVA_HOME in Windows 10
  6. Setting JAVA_HOME in Windows 10
  7. Set JAVA_HOME environment variable & update the system path
  8. Check JAVA_HOME configuration setup using CMD
  9. Related Posts
  10. JavaFX application could not launch due to system configuration
  11. How to open or run a JAR file on Windows
  12. What is JUCheck.exe? Is it safe?
  13. [email protected]
  14. How to set Java path and JAVA_HOME in Windows 10
  15. How to set Java Home
  16. How to set Java path
  17. Check if JAVA_HOME variable is defined
  18. Windows ignores JAVA_HOME: how to set JDK as default?
  19. 15 Answers 15
  20. How to set JAVA_HOME in Windows and echo the result
  21. Set JAVA_HOME properly and echo your results with the following tidbits, and also examine how a proper PATH installation can benefit your local environment.
  22. Search App Architecture
  23. Software AG’s WebMethods update adds tools for non-IT users
  24. 5 dead programming languages we should never forget
  25. Using a business rules engine to streamline decision-making
  26. Search Software Quality
  27. Will codeless test automation work for you?
  28. Tasktop brings new visibility to value stream management
  29. Eclipse Foundation aims open VS Code registry at Microsoft
  30. Search Cloud Computing
  31. Ready to be a GCP architect? Try this quiz and see
  32. Choose the right serverless container service
  33. IBM boosts vertical cloud push with financial services cloud
  34. Search Security
  35. 6 SSH best practices to protect networks from attacks
  36. Companies must train their SOC teams well to prevent breaches
  37. Risk & Repeat: FBI’s web shell removal raises questions
  38. Search AWS
  39. Here’s why Amazon’s global expansion won’t come easy
  40. How Amazon became a force in SMB lending
  41. Amazon Care expands as demand for big tech regulation grows

Как прописать JAVA_HOME?

Картинка для привлечения внимание. Ноги, кафель, ну вы поняли.

Windows:

Приступим к настройке.

  1. Давим по значку рабочего стола правой кнопки мыши -> открывается окно «Система».
  2. На левой панели давим по пункту «Дополнительные параметры системы» -> открывается окно «Свойства системы»
  3. На вкладке «Дополнительно» нажимает на кнопку «Переменные среды. » -> открывается окно «Переменные среды»

Перед вами 2 списка, в верхнем списке указаны все переменные доступные только вашему пользователю, в нижнем — всей системе. В некоторых случаях может потребоваться установить разные переменные JAVA_HOME для нескольких юзеров одной системы, в этом случае для каждого юзера придется прописать свою переменную в списке «Переменные среды пользователя». Мы пойдем обычным путем и установим одинаковую переменную для всех.

  • Необходимо убедиться что переменной JAVA_HOME нет в списке, если есть, давим кнопку изменить и переходим к 6 пункту.
  • Давим кнопку «Создать. «.
  • Указываем имя переменной «JAVA_HOME», в значении переменной указываем полный путь до папки с JDK, например «C:\java\jdk1.7.0_79\».

Окно «Свойств системы» в Windows

Не будет лишним так-же указать переменную «JRE_HOME», она пригодится, например, для разработки портлетов для портала Liferay, для этого по аналогии повторите пункт 6. Как правило, JRE находится в папке с JDK, примерный путь «C:\java\jdk1.7.0_79\jre\».

После установки дистрибьютива JDK виртуальная машина «java.exe» будет доступна в консоли повсеместно. Для выполнения некоторых задач, необходимо так-же предоставить доступ к компилятору «javac.exe», для этого отредактируйте переменную Path. Добавьте в значение переменной «;» и путь до папки с компилятором, например «C:\Java\jdk1.7.0_79\bin\».

Ubuntu:

Для начала необходимо понять куда была установлена Java, выполните команды:

Результатом выполнения команды будет список установленных виртуальных машин Java:

Из этого списка нам потребуется столбик Path. Полный путь до виртуальных машин должен быть до «jre/bin/java», например в нашем случае 0-ой пункт будет иметь полный путь до машины «/usr/lib/jvm/java-8-oracle».

Для установки переменной JAVA_HOME, необходимо прописать ее в /etc/environment, используя путь до машины Java.

Изменения вступят в силу автоматически после перезагрузки, либо мы можем перегрузить переменные окружения командой:

Осталось выполнить проверку:

Если в результате команда напечатает путь до машины JAVA, значит настройка завершена успешно.

JRE_HOME

Не будет лишним так-же указать переменную «JRE_HOME», она пригодится, например, для разработки портлетов для портала Liferay. Как правило, JRE находится в папке с JDK, т.е. значение JRE_HOME = путь до виртуальной машины + «/jre».

How to set JAVA_HOME in Windows 10

In Unix terminology, an Environment variable is a string that holds information such as drive name, pathname, filename, etc. JAVA_HOME is an environment variable which addresses to the directory where Java Runtime Environment or Java Development Kit is installed in the system. To be precise say if you have installed Java in the path C:\Program Files\Java\jdk1.8.0_121 on your computer then your Java_Home is C:\Program Files\Java\jdk1.8.0_121. Basically, JAVA_Home is simply an exemplary used by Java-based programs like Apache Tomcat and other app server tools to find where Java is placed in the system.

These third-party programs make use of the environment variables that point to the directory of JDK or JRE. In simple words, it makes easy for the programs to locate the directory executable like javac in the computer. If you are not using these third party programs, then it may not be mandatory for users to set up JAVA_Home in your system. In this article, we will explain in detail how to set JAVA_HOME as the environment variable in Windows 10.

Setting JAVA_HOME in Windows 10

Set JAVA_HOME environment variable & update the system path

Download and install Java from the official site – java.com.

After installation, Go to Start menu and type Advanced system settings.

Читайте также:  Таблица сравнения windows linux mac

Click on View advanced system settings from the list to open System Properties.

Go to Advanced tab and click on Environment Variables button.

In the Environment Variable window, click on New button under the System variable.

In the Edit System Variable, give the Variable name as JAVA_HOME and Variable value as the path to your JDK directory.

Click on OK.

Now go back to the Environment Variable window and select Path under the System variable.

Click on Edit button to open Edit environment variable window.

Click on New button and type %JAVA_HOME%\bin.

Click OK to apply the changes.

Check JAVA_HOME configuration setup using CMD

To test your configuration, open Command prompt.

Type echo %JAVA_HOME% and hit Enter. This should print the directory of the JDK which the JAVA_HOME is pointing. Instead, if you see a space, it means you have failed in setting up environment variable.

Next Type javac -version which should print the version of Java compiler.

If not it will print a message that the javac is not recognized as an internal or external command. This means the path variable is not set correctly.

Hope this helps!

Date: July 28, 2018 Tags: Java

JavaFX application could not launch due to system configuration

How to open or run a JAR file on Windows

What is JUCheck.exe? Is it safe?

[email protected]

Pavithra is a Windows enthusiast, who loves keeping abreast with the latest in the world of technology.

How to set Java path and JAVA_HOME in Windows 10

Some Java applications require to define JAVA_HOME and Java path. Keep reading and I’ll explain how to do it in Windows 10.

How to set Java Home

You need to do the following to set JAVA_HOME:

Search for Advanced System Settings and launch it:

Go to Environment Variables:

Press “New” button in “System variables” section:

Type name “JAVA_HOME” and value – your path to Java, in my case, it’s C:\Program Files\Java\jre-9.0.4 and press “OK“.

How to set Java path

Find “Path” system variable and press “Edit“.

Press “New” and type “%JAVA_HOME%\bin” to add Java path.

Check if JAVA_HOME variable is defined

We set Java home and Java path variables, let’s check is it really working.

Open command prompt.

We can check Java home variable by typing “echo %JAVA_HOME%“.

We can verify the version of Java as well using “java -version” command.

Windows ignores JAVA_HOME: how to set JDK as default?

How do I persuade Windows to use the JDK instead of a JRE?

This question has been asked before, here and elsewhere:

The trouble is that Windows ignores JAVA_HOME and it also ignores the fact that I made the JDK bin directory the first entry in the path.

When I run java -version from the command line, instead of invoking my JDK 1.6 installation, it runs the 1.7 JRE.

My guess is that this is a problem specific to 1.7, and Windows 7 is doing something it shouldn’t with the registry.

Any ideas on how to fix this?

Edit: Oops. I wrote «first entry in the classpath» above, when I meant «path». Sorry.

15 Answers 15

On Windows, the java executable uses the Windows Registry to locate the default version of Java to run.

The copy of java.exe to run is found by using the PATH environment variable. Unless you take steps to change this, by default a copy will be found in the Windows directory. Since this copy isn’t in a Java runtime directory, it locates one by looking at the registry.

So, you either need to modify the registry, or put the version of Java you want before the Windows directory in your PATH .

In Windows 8, you may want to remove C:\ProgramData\Oracle\Java\javapath directory.

It solved my issue.

I have this issue too. I am running 1.6 but want to build the code I’m working on with 1.5. I’ve changed the JAVA_HOME and PATH (both user and system) to no avail.

The answer is that the installer for 1.6 dropped java.exe , javaw.exe , and javaws.exe into my Windows\System32 folder (Windows 7).

I solved it by renaming those files to java_wrong.exe , javaw_wrong.exe , and javaws_wrong.exe . Only after doing that does it pick up the correct version of java as defined in JAVA_HOME and PATH . I renamed the files thusly because that deleted them in an easily reversible manner.

Hope this helps!

Windows doesn’t ignore anything. This is an issue with your setup; Windows just uses what you provide. It has no special knowledge of JAVA_HOME .

CLASSPATH has nothing to do with Windows, either. To Windows it’s only an environmental variable that gets expanded to a folder location.

Check your %PATH% environmental variable. It’s what’s making Windows find one before the other. The path (as the post you linked to said) should point to %JAVA_HOME%\bin; . Again, the post you linked to gave you a way to set this using a batch file.

Читайте также:  Шрифт для windows powerpoint

(For others who might not know this: The easiest way to inspect the %PATH% is to open a command prompt and type echo %PATH% . You can also get there by right-clicking on Computer in the right pane of the Start Menu and choosing Properties , then Advanced System Settings , and the tne Environmental Variables button.)

How to set JAVA_HOME in Windows and echo the result

Set JAVA_HOME properly and echo your results with the following tidbits, and also examine how a proper PATH installation can benefit your local environment.

If you plan to run software programs like Maven, Jenkins, Gradle or Tomcat, you’ll not only need a local installation of the JDK, but you’ll also want to ensure that you have set JAVA_HOME correctly. Here is how you can accomplish that task with a demonstration of how to set JAVA_HOME in Windows and echo the result to validate that the changes have gone into effect. Also, let’s explore how you can add Java to the Windows PATH, which is another configuration parameter that is often set after a JDK installation.

Three ways to set the JDK JAVA_HOME variable in Windows include:

  • allow the Java installer to do it;
  • use the environment variable editor; and
  • use the command line.

Not every Java installer will automatically set JAVA_HOME for you. The AdoptOpenJDK one will, and it can configure the PATH variable for you as well. But, it doesn’t do it all by default. You must perform a custom install and select one of the following two options to have the OpenJDK installer set JAVA_HOME and PATH environment variables:

  • add to PATH; or
  • set JAVA_HOME variable.

The OpenJDK JAVA_HOME setup tool greatly simplifies configuration.

That’s all there is to it. Once the OpenJDK installation is complete, the JAVA_HOME variable will be configured and the bin directory of the JDK will be added to the Windows PATH. It doesn’t get much easier than that.

If your JDK installation didn’t set JAVA_HOME automatically, you can always open the Windows environment variable editor and set it yourself. This is the easiest way to manually set JAVA_HOME in Windows 7, 8 and 10.

Follow these steps to manually set JAVA_HOME:

  • Open the Windows System Properties Control Panel applet on any version of Windows.
  • Choose Advanced System settings.
  • Click on the Environment Variables button.
  • Click on the New button under System Variables.
  • Set JAVA_HOME as the environment variable name.
  • Set the location of the JDK installation as the environment variable Value.
  • Click OK and close the JAVA_HOME environment variable editor.

How to use the JAVA_HOME environment variable editor in Windows 7.

After you add the new environment variable, close any and all DOS prompts and command windows, because these tools load environment variables only when they first start. If you try to access the JAVA_HOME variable in any windows that were open prior to the change, the variable will come back as null or undefined. But if you open a new command window, scripts that search for JAVA_HOME will run successfully.

The third way to configure the Windows JAVA_HOME environment variable is to use the command line and invoke the setx command as follows:

@REM Configure JAVA_HOME in Windows 10 with setx
setx JAVA_HOME -m «C:\_jdk12.0»
>> setx JAVA_HOME command completed successfully

As you can see, the setx JAVA_HOME approach is relatively simple. Still, command line interface tools can intimidate some people, and this type of manual coding is prone to error. However, when you write scripts to automate the configuration of the environment, the ability to script the process with setx becomes invaluable.

After you set JAVA_HOME in Windows, it’s a good idea to verify that the change has persisted. The easiest way to do this is to echo JAVA_HOME in a command prompt or a BASH shell.

To echo JAVA_HOME in a Windows DOS prompt or command window, you simply bookend the variable with percentage signs:

@REM How to echo JAVA_HOME in windows
echo %JAVA_HOME%
>> C:\_jdk12.0

If you use a BASH shell, or if you have set JAVA_HOME in an Ubuntu environment and need to echo JAVA_HOME in Linux, place a single dollar sign before the environment variable: echo $JAVA_HOME .

The manner in which you get JAVA_HOME within batch files and shell scripts follows the exact same syntax used by the echo command. Bookend the variable with percentage signs and use that variable within your code just as you would any other scripted variable.

Scripts that use JAVA_HOME should always be checked to see if the variable exists. If it does not, an appropriate error message will arise. Here is how the Apache Maven project gets JAVA_HOME in its startup script and reports any errors during the process:

@REM Apache Maven JAVA_HOME Startup Script
@REM ==START JAVA_HOME VALIDATION ==
if not «%JAVA_HOME%»==»» goto OkJHome
for %%i in (java.exe) do set «JAVACMD=%%

Читайте также:  Восстановить размер флешки после linux

$PATH:i»
goto checkJCmd

:OkJHome
set «JAVACMD=%JAVA_HOME%\bin\java.exe»

:checkJCmd
if exist «%JAVACMD%» goto chkMHome

echo JAVA_HOME environment variable is not defined correctly >&2
echo This environment variable is needed to run this program >&2
echo NB: JAVA_HOME should point to a JDK not a JRE >&2
goto error

The JAVA_HOME and PATH environment variables serve two very different purposes. JAVA_HOME simply points to where Java is installed. If you add something to the PATH variable, it makes it available throughout the entire operating system. Of course, many developers who install Java actually want the runtime universally available, so they set the JAVA_HOME and PATH environment variables at the same time.

The big distinction between PATH and JAVA_HOME settings is that the former points to the JDK bin directory, while the latter points to the installation directory. Developers are notorious for mixing up these two settings, which invariably leads to program start issues and the subsequent JAVA_HOME error messages such as «java_home is set to an invalid directory» or «java_home environment variable is not set.»

How to add the JDK bin directory to the Windows PATH.

When you add the JDK \bin directory to the PATH, you can specify the absolute path, or you can get clever and reference the JAVA_HOME environment variable as so:

%JAVA_HOME% bin

It is worth noting that while a JDK installation is linked to the JAVA_HOME environment variable, JRE installations are typically linked to the JRE_HOME variable. The steps to set up JRE_HOME on a Windows machine are exactly the same as those outlined above, with the exception that the JRE_HOME variable will point to the root of the JRE installation, while the JAVA_HOME environment variable in Windows points to the root of the JDK installation.

How to start Java’s JVM Flight Recorder in 3 easy ways

Full GitHub Actions environment variables list for YAML build workflow scripts

Create a distraction free JPA and Hibernate dev environment

How to run Java preview features such as JDK 13 text blocks

  • Transforming Business Continuity for the Hybrid Workplace –HPE
  • Reduce Risk in Moving Workloads to the Cloud –Dell Technologies
  • A New Security Strategy that Protects the Organization When Work Is Happening . –Citrix
  • Fix JAVA_HOME errors quickly | Invalid directory | . – TheServerSide.com
  • JAVA_HOME – TheServerSide.com
  • 5 steps for an easy JDK 13 install on Ubuntu – TheServerSide.com

Search App Architecture

Software AG’s WebMethods update adds tools for non-IT users

Software AG’s WebMethods upgrade aims to ease digital initiatives for IT pros and business users with new app integration, API .

5 dead programming languages we should never forget

These five programming languages may fade into obscurity over the next decade, but the profound influence they’ve had on modern .

Using a business rules engine to streamline decision-making

Get to know some of the details behind a business rules engine, particularly the automated approach it takes to handling critical.

Search Software Quality

Will codeless test automation work for you?

Simple and repeatable — that’s the appeal of codeless test automation. But just how useful is it? Find out in which .

Tasktop brings new visibility to value stream management

Value stream management is central to digital transformation at scale. VSM vendor Tasktop has a new dashboard that gives users a .

Eclipse Foundation aims open VS Code registry at Microsoft

The Open VSX Registry is now at the Eclipse Foundation, which gives developers an open source destination to get VS Code .

Search Cloud Computing

Ready to be a GCP architect? Try this quiz and see

This 10-question quiz, drawn from a new GCP certified professional cloud architect prep guide, helps identify your strengths and .

Choose the right serverless container service

Many IT pros consider serverless containers to be largely hype, while others say it offers real advances in serverless computing.

IBM boosts vertical cloud push with financial services cloud

IBM doubles down on its investment in vertical markets, rolling out a financial services cloud that shares workloads with clouds .

Search Security

6 SSH best practices to protect networks from attacks

SSH is essential, but default installations can be costly. Auditing and key management are among critical SSH best practices to .

Companies must train their SOC teams well to prevent breaches

SOC teams can have all the latest and greatest cybersecurity tools, but unless they have the proper training, it won’t be enough .

Risk & Repeat: FBI’s web shell removal raises questions

The FBI accessed computers — without the knowledge or consent of the owners — to remove hundreds of web shells placed in .

Search AWS

Here’s why Amazon’s global expansion won’t come easy

Amazon would like to strengthen its global footprint, but the e-commerce giant faces roadblocks and challenges today that did not.

How Amazon became a force in SMB lending

Amazon has upped its game with small business lending and credit options for its top merchants, showing more willingness to .

Amazon Care expands as demand for big tech regulation grows

Amazon expands its healthcare delivery service Amazon Care against the growing interest in telehealth and the growing intensity .

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