-
Notifications
You must be signed in to change notification settings - Fork 1
DevFaqObtainSourcesOfAJavaClass
Sometimes it is necessary to open source code for a Java file from your NetBeans plug-in. The source code may be located in the currently open projects, in a library or in the platform JRE. It is assumed that libraries and platform JRE have associated sources in your environment. The associations are configured from the Tools > Libraries and Tools > Java Platform menu items.
Here is an example of how to find a FileObject
corresponding to the class javax.swing.JComponent
:
String classResource = "javax/swing/JComponent.java";
for (FileObject curRoot : GlobalPathRegistry.getDefault().getSourceRoots()) {
FileObject fileObject = curRoot.getFileObject(classResource);
if (fileObject != null) {
// source file object found
// do something, e.g. openEditor(fileObject, lineNumber);
return;
}
}
In the if
block you can do something with the source file you found.
For example, you can open it in the Java editor.
DevFaqOpenFileAtLine describes how.
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqObtainSourcesOfAJavaClass , that was last modified by NetBeans user Admin on 2009-11-06T15:57:14Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.
Apache NetBeans is an effort undergoing incubation at The Apache Software Foundation (ASF).
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
This wiki is an experiment pending Apache NetBeans Community approval.