Java 17 Recipes
Download 3.2 Mb. Pdf ko'rish
|
Java 17 Recipes
- Bu sahifa navigatsiya:
- C:\jdk-17\bin;
- How It Works
1-2. Configuring the PATH
Problem You want to test the Java installation and compile Java from the command line. Solution Add the JDK path to the PATH environment variable. You should have the jdk-17 folder at the root of your OS drive or a custom location. In Windows, search and for select the control panel. Click the Advanced System settings and then Environment Variables. In the System Variables section, find the PATH environment variable and select it. In the Edit System Variable field or the New System Variable field, insert the text C:\jdk-17\bin; in the field “Variable value”. You can also set the JAVA_HOME with the value of C:\jdk-17 and, then, set in the Path the value %JAVA_ HOME%\bin). The semicolon at the end of the text is essential because it separates the new path from the existing ones. Do not insert additional spaces before or after. In Unix and Linux systems, you edit the environment file and modify the PATH variable. In this case, you execute a command such as the following. export PATH=/usr/local/jdk-17/ /bin At last, to find out if the path is properly set, open a command-line window, go to the command prompt, and type the following command. java -version. If you see a screen like the one shown in Figure 1-2 , the correct Java version is installed. Note A terminal (or command prompt in windows) is a command-line interface that allows you to control your operating system by using a command prompt. ChApteR 1 GettInG StARted wIth JAvA 17 5 How It Works To compile and execute a Java program, you must add the JDK path to the PATH environment variable (a string of paths separated by semicolons in Windows and colons in Unix OS). All operating systems use the PATH environment variable to determine where executable files are located on your system to execute any stored or downloaded file on your personal computer. This variable tells the operating systems where the to- run programs reside when a user executes a file. The environment variables can also be stored information used by applications or operating systems. PATH contains a string of directories separated by semicolons in Windows and colons in Unix OS. PATH is used because any executable file in the directories listed in PATH can be executed without specifying the full path to the file. This allows you to run those executables with only the file name from the command line or for other applications to run those executables without knowledge of their directory path. So, when you execute a file, you need to specify the full path to that file, but if the command does not include the path, the OS uses the executable file that matches your file in the PATH. Download 3.2 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling