Java classpath mac os

Как настроить PATH и CLASSPATH для Java в Mac OS

Я пытаюсь запустить Java-программы в Mac OS. Я установил JDK версии 1.7 для Mac, и хотя я получаю ошибки при выполнении Java-программы. Итак, я узнал, что мне нужно установить PATH и CLASSPATH (переменные среды) на Mac, чтобы программы Java успешно выполнялись. Пожалуйста, помогите мне с этим вопросом.

Во-первых, вам нужно найти, где находится каталог bin, содержащий все двоичные файлы Java. Для этого просто

Затем сделайте одно «ls», чтобы увидеть, что у вас есть в этом каталоге. Затем продолжите cd во внутренние каталоги, чтобы добраться до файла bin. Это может немного отличаться от меня, но мой каталог bin находится по этому пути:

Фактически, Home — это путь к каталогу, который содержит подкаталог с именем «bin», который содержит все двоичные файлы java, необходимые для запуска java. Это путь, который необходимо определить в среде PATH. держите этот путь.

Во-вторых, нам нужно проверить, есть ли у нас файл.bash_profile или нет. Просто cd для дома (я имею в виду каталог пользователя) — по любому пути, если вы просто наберете cd и нажмите enter, вы можете пойти в дом. Когда вы находитесь дома, введите следующее:

если вы видите ошибку, связанную с проблемой поиска файла, вам необходимо создать этот файл. Для создания этого типа файла:

вы можете видеть, что редактор для записи в этот файл теперь открыт. Тогда просто напишите это:

и ^ O, тогда введите ^ X, чтобы сохранить этот файл.

В-третьих, выйдите из терминала и снова откройте его и для проверки того, задаете ли вы среду пути или не пишете этот комментарий в терминале:

Если вы видите правильную версию java, появится —Success!

Источник

Java classpath mac os

(MAC OS X)
Java JAR Archives and classpath

The JVM class loader can only find and use JAR archives that are listed in the classpath. There are several ways to add a JAR to the classpath:

  1. Copy the JAR to one of the directories listed in the CLASSPATH environment variable. To see the current value of the CLASSPATH environment variable, open a terminal and type:Another way of viewing the classpath is to run this Java code:
  2. Modify the CLASSPATH environment variable to also include the directory containing the JAR archive.

In csh, the CLASSPATH environment variable is modified with the setenv command. The format is: In sh, the CLASSPATH environment variable can be modified with these commands:

  • Set the classpath at runtime. There are several possible ways of doing this:
    1. Use the -classpath option:
    2. Use the -Djava.class.path system property:
  • Privacy Statement. Copyright 2000-2021 Chilkat Software, Inc. All rights reserved.

    (Regarding the usage of the Android logo) Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License .

    Software components and libraries for Linux, MAC OS X, iOS, Android™, Solaris, RHEL/CentOS, FreeBSD, MinGW
    Azure, Windows 10, Windows 8, Windows Server 2012, Windows 7, 2003 Server, 2008 Server, etc.

    Источник

    PATH and CLASSPATH

    This section explains how to use the PATH and CLASSPATH environment variables on Microsoft Windows, Solaris, and Linux. Consult the installation instructions included with your installation of the Java Development Kit (JDK) software bundle for current information.

    After installing the software, the JDK directory will have the structure shown below.

    The bin directory contains both the compiler and the launcher.

    Update the PATH Environment Variable (Microsoft Windows)

    You can run Java applications just fine without setting the PATH environment variable. Or, you can optionally set it as a convenience.

    Set the PATH environment variable if you want to be able to conveniently run the executables ( javac.exe , java.exe , javadoc.exe , and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

    The PATH environment variable is a series of directories separated by semicolons ( ; ). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should have only one bin directory for the JDK in the path at a time (those following the first are ignored), so if one is already present, you can update that particular entry.

    The following is an example of a PATH environment variable:

    It is useful to set the PATH environment variable permanently so it will persist after rebooting. To make a permanent change to the PATH variable, use the System icon in the Control Panel. The precise procedure varies depending on the version of Windows:

    Windows XP

    1. Select Start, select Control Panel. double click System, and select the Advanced tab.
    2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New .
    3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

    Windows Vista:

    1. From the desktop, right click the My Computer icon.
    2. Choose Properties from the context menu.
    3. Click the Advanced tab (Advanced system settings link in Vista).
    4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New .
    5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

    Windows 7:

    1. From the desktop, right click the Computer icon.
    2. Choose Properties from the context menu.
    3. Click the Advanced system settings link.
    4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New .
    5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

    Update the PATH Variable (Solaris and Linux)

    You can run the JDK just fine without setting the PATH variable, or you can optionally set it as a convenience. However, you should set the path variable if you want to be able to run the executables ( javac , java , javadoc , and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

    To find out if the path is properly set, execute:

    This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set.

    To set the path permanently, set the path in your startup file.

    For C shell ( csh ), edit the startup file (

    For bash , edit the startup file (

    For ksh , the startup file is named by the environment variable, ENV . To set the path:

    For sh , edit the profile file (

    Then load the startup file and verify that the path is set by repeating the java command:

    For C shell ( csh ):

    For ksh , bash , or sh :

    Checking the CLASSPATH variable (All platforms)

    The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class path or the extensions directory.)

    The preferred way to specify the class path is by using the -cp command line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications. Setting the CLASSPATH can be tricky and should be performed with care.

    The default value of the class path is «.», meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.

    To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the following:

    On Solaris or Linux, execute the following:

    If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).

    To modify the CLASSPATH , use the same procedure you used for the PATH variable.

    Class path wildcards allow you to include an entire directory of .jar files in the class path without explicitly naming them individually. For more information, including an explanation of class path wildcards, and a detailed description on how to clean up the CLASSPATH environment variable, see the Setting the Class Path technical note.

    Источник

    Defining Java Classpath under MAC OS X

    I have to port Java applications from Windows to OS X, but I’m pretty new to the MAC world, even to the UNIX world. So I apology if my question is too much trivial.

    I’ve a lot of difficulties to define the classpath under OS X (El Capitan) under which I have installed the last available version of Java 8.

    Let me explain first my environment : :

    Under my home folder I have defined 2 other sub-folders :

    1) /jars which contains multiple jar files (that I’ using frequently for different applications)

    2) /Cinephil which contains only one jar file : «cinephil.jar». The Toto class is into the «cinephil» package

    Now let’s see my concern :

    I start a Terminal session and type :

    In such a case I get a message saying : class Toto not found

    CD Cinephil
    java -cp

    However if I redo the first try but with a different search order in classpath
    java -cp

    The Toto class is well found, but no class belonging to any jar from the Jars folder is found.

    It seems to me that defining a second folder in the Classpath (-cp) is merely ignored.

    Certainly I’m doing something wrong, but I have not found what yet.

    However, I’m wondering whether using twice (or more) the tilde character (

    Note : Because I’m just in test mode (for moving Java applictions from Windows to MAc) for the moment I don’t use the Export command for $CLASSPATH.

    I hope my English is not too bad, and thanks a lot in advance for any advice.

    Источник

    Как настроить PATH и CLASSPATH для Java в Mac OS

    Я пытаюсь запустить программы Java на Mac OS. Я установил JDK версии 1.7 для Mac и, хотя я получаю ошибки при выполнении Java-программы. Итак, я узнал, что мне нужно установить PATH и CLASSPATH (переменные окружения) в Mac, чтобы программы Java работали успешно. Пожалуйста, помогите мне с проблемой.

    2 ответа

    Во-первых, вам нужно найти, где находится каталог bin, содержащий все двоичные файлы Java. Чтобы сделать это просто

    Затем выполните один «ls», чтобы увидеть, что у вас есть в этом каталоге. Затем перейдите к внутренним каталогам и перейдите к файлу bin. Это может немного отличаться от меня, но мой каталог bin находится по этому пути:

    Фактически, Home — это путь к каталогу, который содержит подкаталог с именем «bin», который содержит все двоичные файлы Java, необходимые для запуска Java. Это путь, который необходимо определить в среде PATH. держи этот путь.

    Во-вторых, нам нужно проверить, есть ли у нас файл.bash_profile или нет. Просто перейдите к дому (я имею в виду каталог пользователя) — в любом пути, если вы просто наберете CD и нажмете Enter, вы можете перейти к дому. Когда вы находитесь в доме, введите это:

    если вы видите ошибку, связанную с проблемой поиска файла, вам нужно создать этот файл. Для создания этого типа файла это:

    Вы можете видеть, что редактор для записи в этот файл открыт сейчас. Тогда просто напишите это:

    и ^O, затем введите ^X, чтобы сохранить этот файл.

    В-третьих, выйдите из терминала и снова откройте его, чтобы проверить, установлена ​​ли среда пути или нет, напишите этот комментарий в терминале:

    Если вы видите, что отображается правильная версия Java — Удачи!

    Источник

    Читайте также:  Fscapture для windows 10
    Оцените статью