Java home eclipse windows

Переменная окружения JAVA_HOME – что это такое и она нужна

Во многих статьях в интернете, документации к инструментам для разработки на Java и в книгах зачастую упоминается JAVA_HOME. Что же такое JAVA_HOME?

Что такое JAVA_HOME

JAVA_HOME это переменная окружения, указывающая на директорию с установленным JDK (Java Development Kit, комплект разработчика Java). JAVA_HOME это соглашение, используемое во многих программах из экосистемы Java.

Какие программы используют JAVA_HOME

  • Intellij IDEA, Eclipse, NetBeans
  • Apache Maven, Apache Ant, Gradle
  • Apache Tomcat
  • Jenkins

Некоторые игры, написанные на Java (например, Minecraft), тоже могут требовать установленной переменной JAVA_HOME.

Ошибки, связанные с JAVA_HOME

Если переменная окружения JAVA_HOME не определена, некоторые программы могут выдавать следующие ошибки:

  • Переменная среды java_home не определена
  • Cannot determine a valid Java Home
  • JAVA_HOME is set to an invalid directory
  • JAVA_HOME is not defined correctly
  • JAVA_HOME environment variable is not set
  • JAVA_HOME command not found
  • JAVA_HOME not found in your environment
  • JAVA_HOME does not point to the JDK

При появлении таких ошибок просто установите переменную JAVA_HOME

Как установить переменную окружения JAVA_HOME в Windows

Сперва вам нужно установить JDK или JRE.

  • Установите JDK, если вы занимаетесь разработкой программ на Java
  • Установите JRE, если вам нужно только запустить прикладную программу на Java

После установки JDK либо JRE запишите путь установки, он понадобится.

Теперь щёлкните правой кнопкой на «Мой компьютер» → «Свойства» → «Дополнительные параметры системы» → «Переменные среды…». В разделе «Системные переменные» нажмите кнопку «Создать…» и укажите следующие данные:

Имя переменной JAVA_HOME
Значение переменной Путь к директории JDK / JRE, например:
C:\Java\jdk-11.0.6

Сохраните изменения, кликнув «OK». Теперь выберите в списке переменную окружения Path и нажмите «Изменить…». В конце списка добавьте строчку со значением «%JAVA_HOME%\bin«

Для проверки откройте консоль (Win+R, cmd) и укажите последовательно укажите две команды:

Если вы правильно установили JDK/JRE и правильно установили переменные окружения, вы увидите вывод наподобие этого:

Это будет служить результатом того, что переменная JAVA_HOME установлена правильно и Java работает из командной строки.

Резюме

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

How to change JAVA.HOME for Eclipse/ANT

I am trying to sign a jar file using an ANT script. I know this has to be pointed at the JDK directory for jarsigner.exe to run, but when I echo java.home it returns the JRE directory.

This isn’t a problem for javac, because I can set the executable path. But, that does not exist for signjar.

How do I change the java.home path? When I right-click on MyComputer and go to:

Properties > Advanced > Environment Variables

The «PATH» variable is correctly pointed to the JDK ( C:\program files\java\jdk\bin ).

Update: The file now signs correctly after changing the PATH variable suggested below.

10 Answers 10

In Eclipse the Ant java.home variable is not based on the Windows JAVA_HOME environment variable. Instead it is set to the home directory of the project’s JRE.

To change the default JRE (e.g. change it to a JDK) you can go to Windows->Preferences. and choose Java->Installed JREs.

To change just a single project’s JRE you can go to Project->Properties and choose Java Build Path and choose the Libraries tab. Find the JRE System Library and click it, then choose Edit and choose the JRE (or JDK) that you want.

If that doesn’t work then when running the build file you can choose Run as->Ant Build. and click the JRE tab, choose separate JRE and specify the JRE you want there.

For me, ant apparently refuses to listen to any configuration for eclipse default, project JDK, and the suggestion of «Ant Home Entries» just didn’t have traction — there was nothing there referring to JDK.

However, this works:

Under Windows you need to follow:

Читайте также:  Как облегчить windows 10 home

Start -> Control Panel -> System -> Advanced -> Environment Variables.

. and you need to set JAVA_HOME (which is distinct from the PATH variable you mention) to reference the JDK home directory, not the bin sub-directory; e.g. «C:\program files\java\jdk».

Simply, to enforce JAVA version to Ant in Eclipse:

Use RunAs option on Ant file then select External Tool Configuration in JRE tab define your JDK/JRE version you want to use.

Also be sure to set your JAVA_HOME environment variable. In fact, I usually set the JAVA_HOME , then prepend the string » %JAVA_HOME%\bin » to the system’s PATH environment variable so that if Java ever gets upgraded or changed, only the JAVA_HOME variable will need to be changed.

And make sure that you close any command prompt windows or open applications that may read your environment variables, as changes to environment variables are normally not noticed until an application is re-launched.

In addition to verifying that the executables are in your path, you should also make sure that Ant can find tools.jar in your JDK. The easiest way to fix this is to add the tools.jar to the Ant classpath:

If you are using Eclipse, try the following:

  • Right click on the ant build file, then choose «Properties».
  • Click on the «Run/Debug Settings», then click on the launch configuration file. You should be able to edit it then.
  • After you click «Edit», you should see a new window with a «Properties» tab which will show you a list of Ant build properties. There is a «java.home» property in the list. Make sure it refers to the correct path.

Spent a few hours facing this issue this morning. I am likely to be the least technical person on these forums. Like the requester, I endured every reminder to set %JAVA_HOME%, biting my tongue each time I saw this non luminary advice. Finally I pondered whether my laptop’s JRE was versions ahead of my JDK (as JREs are regularly updated automatically) and I installed the latest JDK. The difference was minor, emanating from a matter of weeks of different versions. I started with this error on jdk v 1.0865. The JRE was 1.0866. After installation, I had jdk v1.0874 and the equivalent JRE. At that point, I directed the Eclipse JRE to focus on my JDK and all was well. My println of java.home even reflected the correct JRE.

So much feedback repeated the wrong responses. I would strongly request that people read the feedback from others to avoid useless redundancy. Take care all, SG

Go to Environment variable and add

till jdk path (exclude bin folder)
now set JAVA_HOME into path as PATH=%JAVA_HOME%\bin;
This will set java path to all the applications which are using java.

and include ANT_HOME into PATH, so path will look like PATH=%JAVA_HOME%\bin;%ANT_HOME%;

Set environment variables

This is the part that I always forget. Because you’re installing Ant by hand, you also need to deal with setting environment variables by hand.

For Windows XP: To set environment variables on Windows XP, right click on My Computer and select Properties. Then go to the Advanced tab and click the Environment Variables button at the bottom.

For Windows 7: To set environment variables on Windows 7, right click on Computer and select Properties. Click on Advanced System Settings and click the Environment Variables button at the bottom.

The dialog for both Windows XP and Windows 7 is the same. Make sure you’re only working on system variables and not user variables.

The only environment variable that you absolutely need is JAVA_HOME, which tells Ant the location of your JRE. If you’ve installed the JDK, this is likely c:\Program Files\Java\jdk1.x.x\jre on Windows XP and c:\Program Files(x86)\Java\jdk1.x.x\jre on Windows 7. You’ll note that both have spaces in their paths, which causes a problem. You need to use the mangled name[3] instead of the complete name. So for Windows XP, use C:\Progra

1\Java\jdk1.x.x\jre and for Windows 7, use C:\Progra

2\Java\jdk1.6.0_26\jre if it’s installed in the Program Files(x86) folder (otherwise use the same as Windows XP).

Читайте также:  Dvd ripper для mac os

That alone is enough to get Ant to work, but for convenience, it’s a good idea to add the Ant binary path to the PATH variable. This variable is a semicolon-delimited list of directories to search for executables. To be able to run ant in any directory, Windows needs to know both the location for the ant binary and for the java binary. You’ll need to add both of these to the end of the PATH variable. For Windows XP, you’ll likely add something like this:

For Windows 7, it will look something like this:

Once you’ve done that and applied the changes, you’ll need to open a new command prompt to see if the variables are set properly. You should be able to simply run ant and see something like this:

Java home eclipse windows

Community

Participate

Eclipse IDE

  1. Home
  2. Downloads
  3. Packages
  4. Release
  5. Eclipse IDE 2020-12
  6. R
  7. Eclipse IDE for Java Developers

Eclipse IDE for Java Developers

Package Description

The essential tools for any Java developer, including a Java IDE, a Git client, XML Editor, Maven and Gradle integration

This package includes:

  • Git integration for Eclipse
  • Eclipse Java Development Tools
  • Maven Integration for Eclipse
  • org.eclipse.epp.package.java.feature
  • org.eclipse.epp.package.common.feature
  • org.eclipse.platform
  • org.eclipse.epp.mpc
  • org.eclipse.justj.openjdk.hotspot.jre.full
  • org.eclipse.buildship
  • org.eclipse.eclemma.feature
  • org.eclipse.egit
  • org.eclipse.jdt
  • org.eclipse.jgit
  • org.eclipse.m2e.feature
  • org.eclipse.m2e.lemminx.feature
  • org.eclipse.m2e.logback.feature
  • org.eclipse.mylyn.wikitext.editors_feature
  • org.eclipse.wildwebdeveloper.xml.feature
  • org.eclipse.tips.feature
  • org.eclipse.tm.terminal.feature

Maintained by: Eclipse Packaging Project

Bugzilla

Bug ID Title Status
516739 Add WindowBuilder to Java package again NEW
513809 [wiring] HttpComponents wiring issue NEW
509799 Symantec reports a Trojan SONAR.AM.C!g24 in eclipse NEW
508091 Duplicate options in Eclipse.ini NEW
521514 Add «Eclipse News» RSS feed to Java Package NEW
522649 News feed plugin not installed on upgrade installs NEW
536469 Use png with transparent icon in the about dialog of Java EPP (and others if applicable) NEW
530698 Using weka api NEW
526611 win64 version missing NEW
498457 FileNotFoundException : org.eclipse.ui_3.108.0.v20160518-1929.jar NEW
489296 Improve out-of-box experience for non-english locales NEW
386806 New Eclipse Icon not used by Eclipse 4.2 on Windows 7 NEW
374170 bugs when updating software NEW
364551 setup automated tests for Java EPP package NEW
414381 Failed to load the JNI shared library «C:\ogramFiles\Java\jre6\bin\client\jvm.dll»\ NEW
458646 Problème démarrage Eclipse NEW
355002 EPP packages need styling NEW
473585 Help system broken after updating from Luna to Mars NEW
487713 FileNotFoundException: introData.xml NEW
382232 Add ‘EGit Import’ to EPP package with EGit ASSIGNED
487722 Dead link for «Remote Help»: Topic not found REOPENED

Bugs listed in italics indicate the bug has been moved to another project.

Bug ID Title Status
382804 Ctrl+C, Ctrl+V shortcuts don’t work while editing Android XML RESOLVED
492163 Add Maven to java package RESOLVED
383193 Taskbar icon doesn’t show Android build progress RESOLVED
490044 [Welcome] Adopt Solstice theme for Java package RESOLVED
386686 the Mobile package should include the Mylyn Bugzilla connector RESOLVED
365594 add code recommenders to java package RESOLVED
358692 Eclipse java package crash in Ubuntu 11.0.4 RESOLVED
356126 fix Mylyn repository URLs in EPP packages for Indigo RESOLVED
356349 update Mylyn URLs for Juno RESOLVED
357020 add Mylyn Hudson/Jenkins connector to Java package RESOLVED
357332 Annotations not shown on overview ruler RESOLVED
389113 Unable to Launch Eclipse after download and setup: «The Eclipse executable launcher was unable to locate its companion shared library.» RESOLVED
406246 zip compression error RESOLVED
468598 Mars RC1 Mac packages are damaged RESOLVED
535504 Open file feature broken in Photon RC2 EPP packages RESOLVED
474204 Include Buildship as part of Java package RESOLVED
534617 [Photon] [java] Add Tip of the Day to the Java Package RESOLVED
528429 m2e to download sources by default RESOLVED
194805 add Error Log view to Java EPP distribution RESOLVED
432716 Consider org.eclipse.recommenders.mylyn.rcp.feature for inclusion into Java package RESOLVED
483914 bug RESOLVED
436206 Re-enable Marketplace Client in Java Package RESOLVED
481475 Scroll lock button being disabled RESOLVED
350079 EGit should be by included in Java package RESOLVED
355058 update repository locations for Juno RESOLVED
275767 [Galileo M7] FileNotFoundException when updating Mylyn RESOLVED
275719 [Galileo M7] packages do not have dropins folder RESOLVED
279203 Add and enable Mylyn update site by default RESOLVED
281448 [update] manager talking to update sites not available RESOLVED
549138 Mylyn cannot be removed from Java IDE package RESOLVED
275558 [Galileo M7] welcome view is not displayed on first startup RESOLVED
275523 [Galileo M7] features appear twice in the about dialog RESOLVED
246466 Missing/extra update sites when installing in either C:\program file or C:\ RESOLVED
248976 «IDE for Java Developers» package is too restrictive by specifying Java 1.5 as required RESOLVED
275520 [Galileo M7] package does not have any update sites RESOLVED
275521 Improve branding for Galileo java package RESOLVED
297341 EPP web page «Download Milestone» link points to old builds RESOLVED
287566 error on update after clean install RESOLVED
341705 I tried to load the eclipse environment in Win Vista OS and got problems restoring workbench. RESOLVED
343869 Add WindowBuilder Core and Swing to the Java package RESOLVED
346703 Inclusion of m2e marketplace on help menu causing confusion RESOLVED
348157 intrusive «preview?» dialog on startup, from WindowBuilder RESOLVED
340312 Indigo Java package logs lots of output RESOLVED
334180 package contains duplicate (and modified?) bundles RESOLVED
313818 Bugzilla connector does not load on Java 1.5 due to missing java.xml.bind bundle RESOLVED
306817 Cannot update from M5 to Eclipse 3.6 M6 RESOLVED
311613 java IDE / m6 / linux has an EclispeCon splash screen? RESOLVED
507104 Include EclEmma in Java Package RESOLVED
507515 Issue encountered when updating and reinstalling ABAP Development tools on NEON version. CLOSED
532067 Open Bugs CLOSED
530726 Mac OS X(Cocoa)64位下载连接无效 CLOSED
515622 Eclipse will not run CLOSED
526343 Constantly returning error message when opening the program CLOSED
501518 Exception while updating external folders CLOSED
521654 Getting error while starting Apache server CLOSED
529170 MacOs didnt open the program CLOSED
548444 The Java GUI is too big CLOSED
497204 resource in project, but error says not open CLOSED
547604 Can’t Install software CLOSED
548562 I am not able to update because of unfound repositories. CLOSED
550404 sgfghg CLOSED
551635 I can’t run eclipse without having a bug on it. CLOSED
543464 2018-12 Installation Error CLOSED
543054 Eclipse crashing while looking at files CLOSED
540168 java 11 CLOSED
539041 Unable to Install CLOSED
541760 Missing Java Developer links for 2018-12 M3 CLOSED
542080 Problems occurred when invoking code from plug-in: «org.eclipse.ui.views.properties.tabbed». CLOSED
543011 java.io.FileWriter, the File cannot be deleted CLOSED
534760 Simple compilation fails in Eclipse Oxygen.3a CLOSED
457081 Add Error Reporting to Java Package CLOSED
435919 Add «Eclipse Code Recommenders» to «This package includes» list CLOSED
435449 Add org.eclipse.recommenders.snipmatch.rcp.feature to java-package CLOSED
436109 update java package maintainer information CLOSED
455363 Allow users to uninstall features from a package CLOSED
461540 Unarchiving error CLOSED
414385 the eclipsec executable launcher was unable to locate its companion shared library CLOSED
384532 The Eclipse executable launcher was unable to locate its companion shared library CLOSED
330226 Inclusion of m2e CLOSED
304968 LinkageError when trying to use Eclipse to run (PDE) Ant scripts CLOSED
349028 fix provider name for org.eclipse.wb.discovery.* CLOSED
353613 Add EGit 1.1 to java-package CLOSED
381216 Zip file for Java IDE RC1 package requires a password? CLOSED
464220 Bug CLOSED
470912 p2 can’t find epp repo for Mars release CLOSED
482370 thanks CLOSED
482285 Mars.1 splash screen does not show progress bar after using console CLOSED
484535 An error removing AppEngine from the project CLOSED
494695 Didn’t update from old version CLOSED
495806 Suboptimal «Visit» link on About Eclipse Features page CLOSED
480756 Switch to root level features to allow users to remove unwanted features CLOSED
478619 Webapp CLOSED
476546 Eclipse Mars.1 RC2 for Java Developers includes CVS cheat sheets but no CVS support CLOSED
476553 Installed Code Recommenders Snipmatch and Mylyn Integration features do not *show* under Installation Details CLOSED
477195 Maintainer/tester information outdated CLOSED
477572 p CLOSED
497192 Eclipse Mars does not open in Windows 10 Pro CLOSED
Читайте также:  Set service name windows service

Bugs listed in italics indicate the bug has been moved to another project.

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