Mac adds Java environment variable success, still error: The main class could not be found or could not be loaded

Source: Internet
Author: User

Batch (SH) files for Windows batch processing (BAT) files converted to Mac

1. bat converted to SH file, write off Echo, title field;

2. Place the '; ' in the bat file Replace the delimiter with ': ';

MAC Add Java Environment variables

1. Open the terminal input CD ~

niko:~ mmk$ open-e. bash_profile

Open a. bash_profile file for editing;

2. Add in. bash_profile

Java_home= '/usr/libexec/java_home '
Export Java_home

Export Path=${path}: $JAVA _home/bin: $JAVA _home/jre/bin
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar:/javafile

Save and close;

3. In the terminal, enter source. Bash_profile is used to save the file and make it effective;

The test path can be printed correctly at the terminal, input echo $JAVA _home/$CLASSPATH See if the path printed is correct;

4. Restart the terminal in the Javafile directory to run Java files, the normal operation is OK;

  Note: Be sure to run Java in the upper folder of the file, or you will get an error Error: The main class could not be found or could not be loaded;

Mac adds Java environment variable success, still error: The main class could not be found or could not be loaded

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.