Source for sun.awt.AppContext and others? - java

I attached the src.zip that came with my JDK, but it seems to be missing a few files.
It's as if I don't have any of the sun.*; packages. I would understand if they maybe got changed out for java.awt.AppContext, but that doesn't exit.
I found AppContext in Container.java (been looking at how Oracle does things), but it shows me bytecode instead of actual code.
Where could I get these files? I looked around on google and found nothing /:
Another thing, when I manually import sun.awt, my IDE shows me that the package exists, but no files in it. Maybe I need to upgrade my JDK? (version 7u45, not too bad)
EDIT on December 30, 2014: Still looking for an answer, now using JDK 8u25

Often time the jar files that are eventually distributed out do not contain the source code of the library but only the built .class files, either aiming to reduce jar size or protect their source code. You may have to refer other resources in order to view the source code. I find www.codatlas.com to be a pretty good place to view some java open source projects. You can find the source code of java.awt.AppContext. It has a pretty IDE-like interface so you should be able to figure out how to use.

These types can be found via the OpenJDK's jdk GitHub Repository.
Here's the implementation for sun.awt.AppContext, which can be found under src > java.desktop > share > classes > sun > awt

Related

SBT package sources and binaries in a single jar

I have found this nowhere on SO or in the documentation, but I would like to create a single jar containing both the binaries and the source code. My project is a mix of Scala and Java, if it adds anything to the question.
I've found this Github project which seems interesting and might enable me to do this, but I could not manage to set it up despite of the instructions. I think it is anyway a bit overkill for my use case. Any idea ?

Need help to integrate a particular vendor's Javadoc to Eclipse

I'm working on big Java enterpriseware (MatrixOne / ENOVIA V6, if you mind). The maintainers provide some kind of Javadoc, which looks like very vanilla Javadoc, and I can read it as HTML in my browser.
However, I'm unable to integrate it to Eclipse, which is painful because I have to make round-trips to my browser. In Eclipse, I just get the dreaded Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.:
After learning that Javadoc can be defined at project and .jar level, I tried to do both, knowing that:
the javadoc folder contains a package-list file, which seems to sanely define the documented packages
the javadoc folder contains the typical folder/subfolder package structure, itself containing ClassName.html files. E.g. the com.matrixone.apps.domain line of my package-list file is matched by a com/matrixone/apps/domain structure, containing lots of ClassName.html files
the javadoc folder doesn't contain a index.html file
When I try to define my Javadoc, the Validate... button fails because of a missing index.html. Then if I create a dummy index.html file, validation works, but I still cannot see the Javadoc when hovering a vendor class/method.
So my question is: What's missing to get this skewed Javadoc to display in Eclipse? Sub-questions I see at this point are:
Was it a bad idea to create a dummy index.html file? If yes, what should I do? (i.e. what tags/meta-information does Eclipse expect?)
A quick comparison of a standard Javadoc file (String.html) vs. one of those vendor Javadoc (DomainObject.html) reveals that meta-information possibly used by Eclipse is absent from my javadoc. For example, my vendor Javadoc includes none of the many <meta> tags present in the String.html Javadoc <head>.
→ Does somebody know the logic/heuristic used by Eclipse to fetch a method/class Javadoc? Maybe point me to the code? With this information I may be able to figure out what's wrong in my Javadoc, and hopefully fix it.
Anything you see fit if you ever faced a similar problem.
I'm currently using Eclipse Juno SR1 on Java 7, under Windows 7.
Of course, feel free to comment to ask for information I forgot to include. Thanks for your help!
I had a similar problem; however, I didn't try to solve it by using a local copy of the JavaDoc for JDOM. Instead, I was trying to use the appropriate URL (the JavaDoc URL for the current version of JDOM is http://jdom.org/docs/apidocs/). So, on the jdom.jar library in the Java Build Path configuration for my Eclipse project, I configured the URL and hit the Validate button. Eclipse seemed to think it was valid, but I still got the same error about not having any attached JavaDoc.
I then discovered that jdom.org also has the JavaDoc for an older version of JDOM (http://www.jdom.org/docs/apidocs.1.1/). So, I tried that on the jdom.jar library JavaDoc configuration and that worked!
The lesson I learned was that the version of the library appears to be taken into consideration when Eclipse is deciding whether the configured JavaDoc is utilized (considered to be attached or not). Make sure the library version matches the version of the JavaDoc for the library (seems obvious now that I've found it).
Hope this helps.

what library I need so I can access this com.sun.image.codec.jpeg in Java?

I'm creating an image watermarking program in java and I imported the followings:
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
but I get an error that says:
Access restriction: The type JPEGCodec is not accesible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar
Does someone know a way to solve this, or what library should I add in order to access that and where I find that library?
Take a look here Link
1. Open project properties.
2. Select Java Build Path node.
3. Select Libraries tab.
4. Remove JRE System Library.
5. Add Library JRE System Library.
As Milad suggested
Even though this WILL work, this goes against all recommended Java Runtime policies. The best practice is to avoid using rt.jar (or any other Sun supplied runtime library for that matter, like tools.jar)
These are in rt.jar, the jar file used as run-time facilities by the JVM, and I would strongly recommend you against adding it as a dependency to your project.
See why here.
The correct way to do what you want to do is described here.
The problem is, that you're importing libraries from the sun.com.* package. Oracle actually discourages the use of these packages, since they could be removed in future releases or may not be available in all JVM implementations.
It's possible that your IDE (which one are you using?) is configured for generating errors if you try to import sun.com.* libraries, in that case a configuration change will allow you to use those libraries, but it wouldn't be a good idea anyway. You should look for other alternatives to the functionality you seek, using libraries with no access restrictions.
Also, if what you want is to simply read or write a JPEG file, take a look at the ImageIO class, there are plenty of useful methods in there.
Maybe your jre system library is 1.8
or eclipse: Project Properties > java compiler > Errors/Warnings > Deprecated API
change Error to ignore/warning

rebuild JDK1.6.8 after some changes

I want to rebuild JDK1.6 after some changes in currency.java in the java.util package. so how can I do it? is there any compiler or builder to make a custom version of JDK?
I try $ javac src/java/util/currency.java but it did not work.
You should not build the whole JDK. Only thing you need is compile your class, put it into a .jar and place it in endorsed folder of a JRE.
I found these build instructions for OpenJDK 6 in the source code repository:
OpenJDK 6 Build README
UPDATE - revisiting this after a couple of years, I came across the following useful blog entry that has links to "Build README" files for a number of Java versions:
https://blogs.oracle.com/kto/entry/jdk_build_readme_collection
Lets hope it stays there, and stays current!
But yea ... if you have just changed one class, then the "endorsed directory" approach is a better idea; see #kan's answer.
Finally, it is generally a bad idea / undesirable to modify the standard class libraries to make your application work:
Your code is immediately non-portable. It will only work on your private flavor of Java.
Each time you upgrade your Java version you have to resync the sources and rebuild. (The "endorsed" approach is simpler, but you still have work to do on each Java update.)
There might be legal issues with redistribution of your modified Java. Talk to an IP lawyer ...

Why isn't javax.activation in the java source zip?

elsewhere eg.[1] it is explained that when you install the java source in
ubuntu, it is put here: /usr/lib/jvm/java-6-sun-1.6.0.20/src.zip
The problem is that it does not contain the javax.activation package
and thus not classes like: javax.activation.DataSource
Why isn't it there?
Must I download the source manually to get that?
[1] Where to find Java JDK Source Code?
The package is javax.activation, not java.activation - and typically, source code for javax... packages isn't included.
The various components of javax use different licenses, so this could be the reason. I've taken the liberty to ask your platform of choice's maintainers here.
I will update this answer as soon as I get an answer.

Categories

Resources