How do I run a doclet in eclipse - java

Referring to the examples given in the post : http://www.javaworld.com/jw-08-2000/jw-0818-javadoc.html#resources
Examples in the post : SimpleDoclet and SimpleOrder
I need to know where do I need to place my SimpleDoclet and SimpleOrder and how do I run this doclet to generate output?
I tried using Generate JavaDoc with the following data :
there are two packages : newPack which contains my classes for which javadoc should be generated and oldPack in which SimpleDoclet is Present
Could you please let me know a solution for this?

I had the same problem; this is my solution:
I create SimpleDoclet in the package codegen.samples
I have exported SimpleDoclet as jarname.jar in C:\xx
In Eclipse, set Doclet Name: codegen.samples.SimpleDoclet and Doclet class path:
c:\xx\jarname.jar
Ask for private visibility (to get all atts and methods)

Related

Eclipse New Java Class Wizard in VS Code

Is there a way to create Java class in VS Code similar to Eclipse New Java Class Wizard?
I would like VS Code to add package and class declarations automatically like Eclipse does.
Couldn't find relevant info in the docs and relevant functionality in plugins.
I faced a similar issue, coming from Eclipse/IDEA background, you can find it difficult to not have a feature in your java IDE to create a new classes, packages etc.
You can use the below VSCode extension : https://github.com/jiangdequan/vscode-java-saber
It is a very handy extension.It provides support/wizard for:
New: Java files(annotation/class/interface/enum/package/JSP/HTML)
Generate Getters and Setters
Copy Qualified Name
Sort Project By Name
Run Maven Goals
Generate Docs
You can try this extension.Search for vscode-java-saber in the extension search and install it.

Javadoc private methods

I've developed my own Doclet to generate csv from Java classes.
I need to launch this Doclet about many projects and I can't edit POM files.
So I'm running using terminal:
mvn -DuseStandardDocletOptions=false
-Ddoclet=com.sadiel.gescontrata.lector.leeclases.LectorDoclet
-DdocletPath=C:\LeeClases.jar javadoc:javadoc
I need to generate documentation for Private methods, so I have try to add -Dprivate but this not works.
Somebody have any idea about what can I do?
Thanks,
Iván.
The private is a Javadoc option. Maven just doesn't expose a property under the same name.
Try specifying the show user property. Like:
mvn ... -Dshow=private
See here for the documentation of this property: https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#show

Could not locate Clojure resource on classpath

I am trying to access some of my clojure functions in my Java code (I am using Eclipse and CounterClockWise). Firstly, I was not sure how to do it? But then I found some answer here.
I am using clojure.lang.RT package for calling .clj files in my Java code. While naming namespaces, .clj files proper conventions has been followed like ns test.clojure.core is in test.clojure package where-in core is .clj file. Also upon following some information, I have added java-source-path (i.e. java-source-path src/test/java) and source-path (i.e. source-path src/test/clojure) in my project.clj.
But, when I run my Java file following error is given - a) Could not locate Clojure resource on classpath b) Attempting to call unbound fn.
Please if anyone in community could help me (assuming I am absolute beginner) through detailed procedure or tutorial I would be grateful, as only information I could get (for using clojure.lang.RT) is very little.
Looking forward to get a complete answer to end my frustration.
I guess you are using RT.loadResourceScript which is causing the proble.
You can try out something like this:
//Load the namespace
RT.var("clojure.core","eval").invoke(RT.var("clojure.core","read-string").invoke("(use 'test.clojure.core)"));
//Find a function in namespace
IFn fn = (IFn)RT.var("test.clojure.core","hello");
//Call that function
fn.invoke();

Using StandardLocation Class in Annotation processor

I am using NETBeans IDE for developing an annotation processor. I have written the annotation processor and then convert it to a JAR and then add this JAR as a referenced library to another java application where i am using the annotations.
Now my question is inside the annotation processor if i want to access the source files( the ones which are annotated) then i try to get a FileObject using the below code
FileObject source = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH,"","demo/MainCopy.java");
but its returning null. Here demo is the package which has the annotated class MainCopy.java . When i read the documentation of StandardLocation class it says for it to work it must be supported , Could somebody help me solve this or guide me as to how to obtain the FileObject.
Thanks

how to avoid "duplicate class" in Java

Suppose I have have a java project myProject and am using an external library jar (someJar.jar), which has a class com.somepackage.Class1.class.
Now I find an updated version of Class1.java which fixes a bug in the original jar.
I include the new Class1.java in my source code under package com.somepackage
When I build the project (e.g., using Netbeans), there is a dist\myProject.jar which contains the classcom.somepackage.Class1.class and a dist\lib\someJar.jar which also contains a class with the same name.
When I run the file (e.g, using java -jar dist\myProject.jar), the new version of Class1.class is used (as I want).
How does Java decide which class file to run in case of such duplicates? Is there any way I can specify precedence ?
Is there any 'right' way to avoid such clashes?
In Proguard, when I try to compress my code, I get a duplicate class error. How do I eliminate this?
Java decides which one to use based on the order of the classpath. List yours first and you'll be fine.
The "right" way would be to fix the orignal source, but sometimes that's not always an option.
I haven't used ProGuard, but I have re-jarred libaries before that had duplicate classes. The solution in my case was to tell Ant to ignore duplicate classes. I would assume ProGuard would have that support too.
Can you not create an updated jar file which contains the bug fix? It's going to make things a lot simpler if you don't have two versions of the same fully-qualified class around.
1) Updated Jar is a better solution.
2) Use a different class name. Is there a reason, why you want to use the same class name and same packing? I don't think there is a reason.
3) create a wrapper/ proxy class, that encapsulate all the calls to the jar and you can decide to call this new class that fixes the bug ( provided it has a different name and packaging)

Categories