When Javadoc processed a package-info.java file in Java 8, the output placed the Javadoc comments (except for the summary sentence) after the generated class and other summary tables. Here is a Java 8 example: https://docs.oracle.com/javase/8/docs/api/java/nio/file/package-summary.html
Sometime between Java 8 and Java 11 this changed, and the Javadoc output in Java 11 now places all Javadoc comments before the generated class and other summary tables. Here is the same example in Java 11: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/package-summary.html
What I'd like, but have been unable to find, is a way to control this behavior in Java 11. I'd prefer to revert to the Java 8 behavior (in Java 11) or, even better, to be able
to control this behavior such that some package comments appear before and some after the summary tables.
Is there a way to control this Javadoc behavior in Java 11? At the moment I am constrained to Java 11 and cannot use features from earlier or later versions.
From Oracle
You can customize the content and format of the javadoc command output
with doclets. The javadoc command has a default built-in doclet,
called the Standard Doclet, that generates HTML-formatted API
documentation. You can write your own doclet to generate HTML, XML,
MIF, RTF or whatever output format you want.
The StandardDoclet delegates to HtmlDoclet. You might be able to get away with subclassing that and overriding generatePackageFiles.
IMO probably not worth the effort, but hey.
Related
I inherited some Java code that gets data from an XML file and inserts the data into Microsoft Word document. The Java code uses two files as input. One is the XML file with data and the other is a Microsoft Word Document which is used as a template for the output file. The Word template has Content Control objects which are mapped to XML tags from the XML file. When the Java program is executed, it uses the Word template and the XML file to "bind" the two files together using the XML mappings in the Word template. The output from the code is a Word document in the format of the template, but with updated data from the XML file.
The binding is from the DOCX4J Library namely "Docx4J.bind()". This method uses JAXB.Content from a jar named Javax.xml.bind.JAXBContext. The problem is the JAXB library and methods are all deprecated and completely removed from Java 9 and forward. So it appears the only way to make this bind method work is to stay in Java version 8. I have been asked to find an alternative to JAXB.Context so that the Java code can be compiled and run in a Java 13 environment.
My question is this:
Is there a comparable replacement for JAXB in Java 11,12 or 13? If so, can you please point me to some documentation to find out more about it.
Thanx for your input and help.
JAXB is no longer shipped in recent JDKs, but JAXB itself is still readily available, in the reference implementation, and in MOXy. JAXB is not deprecated.
Have a look at https://www.docx4java.org/downloads.html
As it says there, just add ONE only of docx4j-JAXB-ReferenceImpl or docx4j-JAXB-MOXy. (It is only docx4j-JAXB-Internal which won't work on the versions of Java of interest to you)
You can use either the 8.x series or the 11.x series. The 8.x series is compiled for Java 8, whereas the 11.x series is compiled for Java 11+ and includes module-info.
Either will work on Java 13 (for docx4j 8, the class path at least). At present, the 8.x series tends to get new features first.
So, in summary, you should not encounter any problems at all running Docx4J.bind on Java 13!
I'm writing documentation for my java file. In that documentation, I want to add some html links at the end of each generated file. For that, what I have to use while writing java documentation?
If you are using Eclipse as IDE, you can use the plugin JAutodoc:
http://jautodoc.sourceforge.net/
To add a default text at the beggining of each text file.
According to the javadoc manual (can't find a newer version right now), you should use -footer when you generate your java API documentation from the CLI, for instance:
javadoc -footer "<b>Copyright 2015 Lakshmi Prasanna</b><br>" com.mypackage
Here's a similar example, but that uses -header instead.
Now, if you use a good IDE, at the very least it should allow you to type that somewhere in the project settings. Back in the day Eclipse wasn't very flexible, so I had to make an Ant script (yuck).
EDIT:
One limitation with this approach is that the CLI -options depend on the tool. This works with the standard javadoc command but might not work with another vendor's doclet. However I'm not sure there's a universal way to achieve what the OP asked.
Anyway, it seems to be: NOT -footer but -bottom.
Javadoc generated by the JDK8 is completely different compate to that of JDK7.
In new Javadoc, header text is overlapping and layout completely messy. I understand after reading
Oracle documentation that Doclet is reason for creating html view of Javadoc. Is there any way to
use Doclet associated with JDK7 to generate the the Javadoc..?
If you are referring to the doclet, you can turn the doclet off by adding -Xdoclint:none to the command line call to javadoc
http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
If you just want the old CSS used in Java 7 this other Stack overflow question contains the css you can use instead:
JDK8: Getting back the JDK7 look for javadoc
I wanted to decode a Base64 string in my XPage for which I was using sun.misc.BASE64Decoder class. But according to Java developer should not write programs that call 'sun' packages. I was searching for an alternative when I stumbled on com.ibm.misc.BASE64Decoder. It worked for me with same results as sun.misc.BASE64Decoder. So I would like to know if it is okay for developers to use this package and its classes? Or is it to be avoided like 'sun' package?
Also I know that I can use Apache Commons for Base64 but I would like to minimize my dependency on external JARs.
With com.ibm.misc.BASE64Decoder you'll have exactly the same problem as with sun.misc.BASE64Decoder: it's an internal class which only exists in a specific JVM implementation, in this case IBM's JVM.
Note that there is no com.ibm.misc.BASE64Decoder in Oracle's JVM, so if you use this class, your program is not going to work on Oracle's JVM; it will fail with a NoClassDefFoundError.
You could use the method that mre refers to in his comment, which is in the class javax.xml.bind.DatatypeConverter - part of the JAXB API, which is part of the standard Java API (since Java SE 6).
I've been running Checkstyle on some code and looking for a good example to get to grips with how to add comments for specific purposes.
For example Checkstyle says I should add comments for constants/class variables. Yet nowhere in the official docs Oracle host, can I find an example of this.
I was looking in various places, but couldn't find a concise example...
1
2
3
4
5
I figured if I could get my hands on the source code for the Java Calendar class, it would be a good example. You can see all sorts of constants in the API docs of that class.
See here.
How can I either:
1) Get my hands on the source for Calendar?
2) Find an example of how you'd document code like this in Javadoc (Checkstyle flags it needs it):
private static final int NO_OF_RECORDS = 10;
On the Java 6 download page, under the "additional resources" section, you can download the source code for the whole JDK.
Additionally, most IDEs automatically index the source code for Java's library classes so you can open those classes transparently.
Oracle's current java 6 source download links to http://download.java.net/jdk6/source/ which should contain the entire java library source.