Where is Java source code for various com.sun.* packages on Leopard?
Asked Answered
V

6

7

I am working on my MacBook at home, running Leopard, with the latest JDK 1.6 from Apple installed. In IDE, I'd like to browse source code for com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel, but IDE cannot find it. Another example I'd like to browse is com.sun.java.swing.plaf.nimbus.ButtonPainter.

What JAR or ZIP do I need to add to my IDEA project in order to browse com.sun..nimbus. classes inside IDE I'm only interested in Leopard, because this works fine on Windows with Sun's JDk.

I know the Nimbus classes are available, because my app runs with the Nimbus Look and Feel.

Vying answered 21/7, 2009 at 12:49 Comment(0)
H
2

The Nimbus classes are here in my 1.6 Mac installation:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/classes.jar

and I would jad them if you need the source. I use JadClipse to view jad'ed source inside Eclipse. It's not perfect of course, but serves in a pinch.

You can also get JDK 1.6 source here:

If you extract it, you can find the Nimbus source down under Work/j2se/src/share/classes/com/sun/java/swing/plaf/nimbus

So could theoretically hook that up to the classes.jar and maybe get something to work too.

Hesitate answered 21/7, 2009 at 13:28 Comment(3)
Jad don't lend well to the new byte code constructions in Java 6.Accommodation
@AlexMiller: On-the-fly decompilation is fine but results often need some cleanup to the usable in debugger. Do you happen to know where to get such "unofficial" sources for JDK 1.6 as single bundle?Wenonawenonah
No, but you might find a better bet is to look into the new Oracle OpenJDK mac port that they just released last month.Hesitate
S
1

Unfortunately, the source for these libraries is not often distributed. If you want to inspect the code, you could download a decompiler and decompile the jars in your install.

Here is a link to wikipedia that has a few follow-up links for download sites for JAD, a decompiler that will do the job.

Strobile answered 21/7, 2009 at 12:53 Comment(0)
H
1

Best bet is, as others have pointed out, to decompile the code.

However, everyone else has suggested JAD, I don't like it much. JD-GUI is a MUCH better decompiler as it can look into jars and link sources so you can inspect the code much easier. I've sifted through some rather complex code with this easily.

http://java.decompiler.free.fr/

Hamburg answered 21/7, 2009 at 14:57 Comment(0)
V
0

The source code for the JDK can be obtained (under varying licenses) at OpenJDK. I'm not sure how you'd go about integrating it with IntelliJ, however.

Viglione answered 21/7, 2009 at 13:23 Comment(0)
F
0

On the Mac, the sources to the JDK aren't bundled by default.

You'll need to download the XCode stuff from the Apple Developer Network - there's an installable package in that download for the JDK sources. Whether it contains the com.* stuff or not is a different question ;-)

Forster answered 25/9, 2009 at 9:40 Comment(0)
A
-2

The Source code comes when you install the JDK. Look into the JDK Directory for src.zip.

Most Java packages are there, I am sure Swing will be there too.

Arluene answered 21/7, 2009 at 13:19 Comment(1)
Often com.sun.* are not in the available source as they are not part of the JDK.Hesitate

© 2022 - 2024 — McMap. All rights reserved.