The unexpected token error is reported after Java environment variables are added to the/etc/profile file.

Source: Internet
Author: User

Error description:

After saving the Java environment variables at the end of the/etc/profile file and executing "source/etc/profile" or "re-Logon", the following error is reported:


Run the "env" command to check the system environment variables.

Cause analysis:

Because FlashFXP is used to open the modified/etc/profile file in Windows, the file format changes. Dos and Windows use carriage return + line feed CR/LF to represent the next line, while UNIX/Linux uses the line break LF to represent the next line, and mac OS uses the carriage return CR to represent the next line. CR is represented by the symbol "\ r", the ASCII code in decimal format is 13, and the hexadecimal code is 0x0D; LF is represented by the "\ n" symbol, and the ASCII code is 10, the hexadecimal value is 0x0A. Therefore, on Windows, line breaks are represented by 0d 0a in text files, while on UNIX and Apple platforms, line breaks are represented by 0a or 0d in one byte. Generally, the Runtime library on the operating system automatically determines the line feed format of text files. For example, if a program runs on Windows, a text file in CR/LF line feed format is generated, and a text file in LF format is generated when it runs on Linux. Using another line break file on one platform may cause unexpected problems, especially when editing program code. Sometimes the code is displayed normally in the editor, but errors may occur due to line breaks during editing. The above error is that the line break is converted to CR/LF because the profile file is opened in Notepad on Windows, in Linux, the unexpected token error is reported because the return letter CR is not recognized.

Solution:

We can use the Notepad ++ text editor to convert the text formats of different operating systems. After you use Notepad ++ to open the profile file, choose "edit"> "file format conversion"> "convert to UNIX format" on the menu bar. After saving the file, the Windows line break CR/ LF to Linux LF, if you run "source/etc/profile" in Linux, the preceding error is not reported and the environment variable is set successfully.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.