Update path variable что это
Path variables
Path variables are placeholders that stand for absolute paths to resources that are linked to your project but are stored outside it. If you are working in a team, these absolute paths on the computers of your teammates may differ. With path variables, you can flexibly share your code so all the references to the linked resources are resolved properly as the path variables accept the values according to the configuration on each specific computer.
In PyCharm, there are some pre-defined variables:
$USER_HOME$ : stands for your home directory.
$PROJECT_DIR$ : stands for the directory where your project is stored.
Create a new path variable
For example, you have a Python script that processes some data stored in your system in the reports.csv file. You create a run/debug configuration to run this script and want to share this configuration with your teammates through the VCS.
Share the run/debug configuration through your version control system.
After your teammates update their projects from VCS, they will change the DATA_PATH variable value so that it points to the data directory on their computers.
Ignored path variables
When you open a project, PyCharm checks if there are any unresolved path variables. If the IDE detects any, it will ask you to define values for them. If for some reason you don’t want to do that (for example, if you are not going to use files or directories with the unresolved path variables), you can add them to the list of ignored variables.
You can also use the list of ignored variables if, for example, a program argument passed to the JVM in a run/debug configuration has the same format as an internal ($SOME_STRING$) path variable. In this case, you can add this parameter to the list of ignored variables in order to avoid confusion. Enter SOME_STRING to the Ignored Variables field in the Path Variables dialog.
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.
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:
Update the PATH Variable (Solaris and Linux)
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 (
Then load the startup file and verify that the path is set by repeating the java command:
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.)
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).
How to update system PATH variable permanently from cmd?
We can use setx as discussed here.
But this command can just make changed to user PATH variable not the system one.
How can we make a similar system wide command?
6 Answers 6
Type setx /? to get basic command help. You’ll easily discover:
We may destroy the current system’s PATH variable. Make sure you backup its value before you modify it.
One problem with %PATH%, is it includes the user’s path. If you don’t mind Powershell, you can run the following
If you want to add some location to the PATH environment variable on user level, use the following on the command line:
Why the strange syntax? First, you do not want to expand the system PATH variable but keep it as a symbol, otherwise you will not participate in future additions to the system PATH variable. Therefore, you have to quote the % characters with ^.
If you use this in a command script, you have to use double %% instead of ^%.
The » encloses a string that contains spaces. If you do not have spaces, you can omit the quotes.
The added string has to follow directly without space so the whole thing forms a single argument to the setx command.
How to update PATH variable permanently from Windows command line?
If I execute set PATH=%PATH%;C:\\Something\\bin from the command line ( cmd.exe ) and then execute echo %PATH% I see this string added to the PATH. If I close and open the command line, that new string is not in PATH.
How can I update PATH permanently from the command line for all processes in the future, not just for the current process?
I don’t want to do this by going to System Properties → Advanced → Environment variables and update PATH there.
This command must be executed from a Java application (please see my other question).
7 Answers 7
However, setx will truncate the stored string to 1024 bytes, potentially corrupting the PATH.
But if you look in the registry or on a new cmd.exe with «set p» you can see the new value.
The documentation on how to do this can be found on MSDN. The key extract is this:
To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message with lParam set to the string «Environment». This allows applications, such as the shell, to pick up your updates.
Note that your application will need elevated admin rights in order to be able to modify this key.
You indicate in the comments that you would be happy to modify just the per-user environment. Do this by editing the values in HKEY_CURRENT_USER\Environment. As before, make sure that you broadcast a WM_SETTINGCHANGE message.
You should be able to do this from your Java application easily enough using the JNI registry classes.
Update Windows Path Without Rebooting
Updating the PATH environment variable without rebooting in Windows
I haven’t used Windows for over a decade, but this page gets a lot of hits, so I leave it here assuming and hopeful it is helpful.
I find it quite annoying that whenever I read instructions that include adding an environment path variable you are asked to reboot your machine for changes to take effect. I know there has GOT to be a way to do it. Well, I know a way, but it’s someway kludgy.
Here is how I do it (I’m really hoping someone will comment and tell me a better way)
Now, reboot your computer! Argh! J/K
Here is the kludgy hack that I use so I don’t have to reboot. (But it will not work in all cases, which is why I don’t like it, so please, if you know of a batch script or something I can run that will apply the changes made to the environment variables without rebooting, please post a comment.)
Open a comment window and type SET PATH=%PATH%;C:\CmdShortcuts
You can type PATH again to see your path variables. Your new path should be added. The problem with this is that this new path variable is only good inside this command window. If you are doing command line stuff this works, but if you close your cmd window the change is lost.
Dustin Davis is a software engineer, people manager, hacker, and entreprenuer. He loves to develop systems and automation. He lives with his wife and five kids in Utah.