The Java version of Mac OS and the JDK Source Code cannot be found in eclipse.

Source: Internet
Author: User
Document directory
  • 1. How to query the local Java version?
  • 2. Where is the Java Control Panel on Mac?
  • 3. solve the problem that the source code cannot be found in eclipse. the JAR file/system/.../classes. Jar has no sourece attachment.
  • 4. Modify the source code bound to eclipse
Brief Introduction

1. Mac OS (version 10.8) comes with JDK or Java 6, but no source code. Apple is responsible for releasing and updating Mac OS's built-in Java 6, which is slightly different from Oracle's Java 6, for example, there is no RT. jar, replaced by classes. jar for more information, see the http://my.oschina.net/hmj/blog/79939

2. Oracle does not provide Java 6 for Mac OS, but Java 7 and source code can be downloaded from the official website of orace. Oracle provides detailed installation guide, which is not described in this article. See http://www.java.com/zh_CN/download/help/mac_install.xml

3. on Mac OS, Java 6 and Java 7 can coexist. I have not tested this and I will not introduce it. There are a lot of posts on the Internet.

4. Introduce where to download the source code of Java 6 and solve the problem that eclipse cannot find the source code. The JAR file/system/.../classes. Jar has no sourece attachment.

Details 1. How to query the local Java version?

Open the terminal and enter Java-version

Yangdemacbook-air :~ Feiniao $ Java-version

Java version "1.6.0 _ 51"

Java (TM) se Runtime Environment (build 1.6.0 _ 51-b11-457-11m4509)

Java hotspot (TM) 64-bit server VM (build 20.51-b01-457, mixed mode)

2. Where is the Java Control Panel on Mac?

Note that the control panel is available only when Oracle Java 7 is installed. For details, see the official website of orace.

Click the apple icon in the upper-left corner of the screen.

Go to system preference settings

Click the Java icon to access the Java Control Panel.

3. solve the problem that the source code cannot be found in eclipse. the JAR file/system/.../classes. Jar has no sourece attachment.

Cause analysis:

The JDK that comes with the system does not have the source code package. You need to download it from the apple official website.

The solution is as follows:

3.1 download the Java development kit containing the source code

There are many other things in the following https://developer.apple.com/downloads/index.action Development Kit, which is not introduced here.

Log on with your Apple id. The first login is a prompt for registration. Just click it all the way. To this page

The latest version of the Development Kit is as follows: Java for OS X 2013-004 developer package. After downloading the package, it is installed normally.

On the internet to see a lot of blog introduction is to download http://connect.apple.com, but this address can not open, it is estimated that the previous download link, has expired.

3.2 installation and configuration

Refer to blog
Http://www.blogjava.net/lsbwahaha/archive/2012/10/16/389692.html to perform the following steps

1. Sudo-S

2. CD/system/library/frameworks/JavaVM. Framework/home

3. ln-S/library/Java/javavirtualmachines/1.6.0 _ 35-b10-428.jdk/contents/home/docs. jar.

4. ln-S/library/Java/javavirtualmachines/1.6.0 _ 35-b10-428.jdk/contents/home/src. jar.

5. Similar to Windows, use command + Click in eclipse to view the source code of a class. Select "add source" and select the SRC. JAR File above.

Note that the above version number must be modified based on the software version number on your computer. In fact, press the tab and you will find it yourself.

I have successfully followed this operation, but the above commands 3 and 4 do not think it is OK to execute. On the source code interface added by ECLIPSE, you can directly find the source file that executes the soft connection, because all users of these files have the read permission.

This operation may take into account putting the source code into the Java directory of Mac OS itself.

In addition

Running type Java on the terminal shows that Java is located in/usr/bin/Java and is a soft connection.

Java->/system/library/frameworks/JavaVM. Framework/versions/current/commands/Java

3.3 java_home settings

Refer to this blog http://kennylee26.iteye.com/blog/1772638.

4. Modify the source code bound to eclipse

If the system's Java version and source code are updated, you need to re-bind the source code of the new version. How can this problem be solved?

In another similar scenario, when specifying the source code for Android. jar, the source code of the wrong API version may be selected. How can I modify it?

The procedure is as follows:

Open the build patch and libraries tab, find classes. jar, select it, and click Edit on the right to go to the configuration page.

Related Article

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.