I'm trying to write an SVN Post-Commit hook to generate javadoc on a webpage whenever someone submits any changes to relevant files.
I was new to the hook concept, but I didn't expect to run in any strange errors when generating the javadoc.
java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc
at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46)
at com.sun.tools.doclets.internal.toolkit.util.Util.isDeprecated(Util.java:811)
at com.sun.tools.doclets.formats.html.AbstractIndexWriter.printComment(AbstractIndexWriter.java:186)
After a few succesful searches on StackOverFlow I discovered it had something to do with third-party-annotations. (I make use of the Play framework and that uses a number of other libraries)
So I included everything in a script:
#!/bin/sh
CLASSPATH="~/Play/play-1.1.1/;"
javadoc -d ~/svndoc/ -classpath $CLASSPATH -sourcepath ~/svntest/avon/trunk/ScoreDB/app #packages
But this generates the exact same errors. Sometimes there are 10 warnings, but most of the time there are 27 of them.
Could you guys help me out?
Thanks in advance,
Jasper
Your classpath looks wrong. First, there should be no ; in it (in Unix, the separator is :, but it is not needed at the end). Secondly, do you really have the individual class files in this directory? If there are jar files, you need to either list them individually, or put a * there (but pay attention that bash does not expand it, since you would need : instead of spaces between).
I have no idea if this would solve the problem, though.
Related
Getting the below error when trying to initiate call.
<SIP/xx.xxx.xxx.xx-00000000>AGI Rx << VERBOSE "No script configured for URL 'AGI://localhost/xxx.agi' (script 'xxx.agi')" 1
Can anyone help me to resolve this error.
Thanks
This is already old, but still i got stucked yesterday with same issue, and found the solution.
A lot of people saying about the classpath where your properties file should be, and they are right.
As long as you running the asterisk jar in terms to run the test script, it doesn't have the properties file inside with YOUR script pointed there. So you need to direct it.
Try to use this command, but modify it with your path:
java -cp /home/your user/folder with project/src/main/java/:/home/your user/folder with jar file placed/asterisk-java-2.0.2.jar org.asteriskjava.fastagi.DefaultAgiServer
org.asteriskjava.fastagi.DefaultAgiServer - this is the path which you use to run a server. Even if you will write something like:
java -jar asterisk-java-2.0.2.jar
it will call the DefaultAgiServer anyway.
So my point is, that the classpath here is a keyword, and command above will solve this problem for sure =)
UPD: Although it fix the issue with classpath of .properties file, that doesn't mean that it will solve this problem, in case if your script placed in additional packages =)
If path to your script is something like
com.yourcompany.yourpackage.YourScript
that mean that you need write down the same thing in a properties. Something like:
hello.agi = com.yourcompany.yourpackage.YourScript
Hope this will help somebody ;)
This error is writed by your java code. See java code for more info about how to do call. Most likly need do something like
AGI://localhost/xxx.agi?function=func
I'm looking for a way to convert the javadocs from my open source project (generated in Eclipse) to GitHub MarkDown, or come up with some other simple solution to display my documentation on GitHub (shy of simply adding a docs directory). Is there a simple solution for this? Can I simply point the GitHub README.md to my docs directory? Is there something more elegant? I have been striking out on Google.
I don't think it's possible to make a usable Javadoc with MarkDown. The best solution is probably to commit the Javadoc you generated on the gh-pages branch (or in the docs/ directory depending on the settings of your project). It will be available at :
http://username.github.io/projectname
Here is an example from one of my projects:
http://ebourg.github.io/jsign/apidocs/
Currently you can also host your Javadoc with Github Pages from not only a gh-pages branch, but directly from the /docs folder within your master branch. You can check the help section on this topic, here (also check attached image below).
Also, there's a project on Github that targets some conversion of Javadoc to Markdown (have not tried it yet, just leaving the reference).
Do NOT check Javadocs into the source control for your project
Especially not into the master branch! I followed the other answers to this question for about a year before deciding it was a really bad idea. Why?
It made it too difficult to review diffs. I even made a script (see below) to update only the Javadoc pages that substantially changed, but it still was a mess.
It fooled IntelliJ's refactoring tools. I just tried to change .x() to .getX() and had to approve/reject every "x" in the Javadocs. Maybe I forgot to exclude the folder in IntelliJ, but if you ever use sed/grep/find on your project, you have to remember to exclude it every time.
It adds a bunch of data in git that just shouldn't be there, potentially making pull and clone commands take longer... FOREVER! Even if you later "remove" the folder, it's still stored in git.
Where should javadocs go?
It's probably best to post them on https://javadoc.io/, your web site, or AWS or heroku. If you must check javadoc into source control, make a separate project just for Javadocs so you'll never need to look at the diff. You can follow other people's answers for how to do this.
"I read your post, but I'm doing it anyway"
Here's my script to update fewer javadocs. It only copies files with substantial changes from the target/apidocs folder to the docs/apidocs folder. It also adds new files and deletes no longer used ones. I think I used poor names, newfile and oldfile, but it works. I mean, it wasn't enough to justify checking javadoc into my project's source control, but it helps.
#!/usr/bin/env bash
# -I means ignore lines matching a regular expression
# -q means "quiet" - only tell whether files differ or not
# -r means "recursive" - explore subdirectories
# -N means "treat absent files as empty" which makes absent files show up in Quiet mode.
diff -I '<!-- Generated by javadoc ' \
-I '<meta name="date" content="' \
-I '<title>' \
-I 'parent.document.title=' \
-N \
-qr \
docs/apidocs/ target/apidocs/ > target/javadocPatch.txt
# Now read in the output file created by the previous command and
# Update only files that have substantial changes.
while read ignore1 oldfile ignore2 newfile ignore3
do
if [ ! -f "$oldfile" ]
then
echo "Added $oldfile"
echo -n >$oldfile
cp -fu $newfile $oldfile
elif [ ! -f "$newfile" ]
then
echo "Deleted $newfile"
rm $newfile
else
echo "cp -fu $newfile $oldfile"
cp -fu $newfile $oldfile
fi
done < "target/javadocPatch.txt"
It might be a bit off topic but I believe what OP is looking for is a mechanism to automatically make javadoc available as a new version of the project is published.
If this is the case, then you can try: http://javadoc.io
It's a free service hosting javadocs for open source project, currently supporting maven central and bintray (jcenter).
You can generate a link to the latest version of your project. For example, this link https://javadoc.io/doc/org.springframework/spring-core always point to the latest version of spring-core, which is 5.2.0.RELEASE at the time I write this answer.
Declaimer: I run javadoc.io
This question was already asked here on Stack Overflow, BTW even after reading the answer provided, I do not manage to add MyOwnAnalyzer, so that I can use it directly from Luke.
Please can someone help me on the right way to do, that is how and what to do so that MyOwnAnalyzer can be usable directly from Luke?
Can I do this (it did not work, may be my included jar are incomplete?):
java -cp .;d:\java\mylibs\MyOwnAnalyzer.jar -jar lukeall-3.5.0.jar
(MyOwnAnalyzer.jar was built from Eclipse and contains : MyOwnAnalyzer.java, MyOwnTokenizer.java, and MyOwnToken.java inside a subdirectory com.MyCompany... Eclipse added META-INF and manifest.mf for me)
Maybe I am wrong in adding classpath and MyOwnAnalyzer.jar with my command line?
Or must I build Luke from source including MyOwnAnalyzer somewhere in its directory?
Or is there something else to include/write so that my analyzer can be usable and imported from Luke? (looks like there is a mechanism to detect all classes that subclasses Analyzer - MyOwnAnalyzer is already declared as "extends Analyzer" )
BTW, even if it not really the same question but still in the same topic of using a custom analyzer from Luke... si I have an Error when using the tab Analyzer Tool I get Error analyzing:com/google/common/io/CharStreams , this lib is included in a jar, where I included a main that do a sample analysis to check and everything work fine when using it alone. If I use it as explained by JPountz, from Luke, I can see MyOwnAnalyzer from all the Luke tabs, but it did not work!
from the Luke code source, I think what throw the exception this is located somewhere inside the method analyze.
Note: The call to CharStreams.toString(input); is to transform the Reader input to a String inside MyOwnTokenizer.
Java ignores the -cp option when the -jar option is also used. You need to run Luke this way:
java -cp lukeall-3.5.0.jar;MyOwnAnalyzer.jar org.getopt.luke.Luke
I am working on a team project in Java. One requirement is that we dynamically populate a drop-down menu of all classes that implement a certain interface. New classes can be added after compile time. To accomplish this we are using reflection.
Problem: All of the drop-down menus are blank on my system. I cannot for the life of me figure out why they are not populating. All other 5 team members have it working on their system.
Things I tired that didn't work:
1) Installing most recent eclipse (galileo) because rest team was using it
2) Re-install most recent java release (jdk1.6.0-17 and jre6)
3) Check PATH and JAVA_HOME variables
Any thoughts as to what else I can try or if something I did should have solved it and didn't? It is driving me crazy.
Edit:
I should have been clearer that we are developing in a team. We are using SVN for version control and we are all running the exact same source code. I even tried checking out a fresh copy of the entire tree from SVN, but I had the same issue with reflection on my system while it worked for teammates.
The team created an executable jar and that ran on everyone's system fine except for mine. Everything worked for me except the reflection bit.
You need to debug your application. This means you have to systematically explore possible causes of the problem. Here are some things that come to mind:
Could your GUI be failing rather than reflection? What if you output with System.out.println() rather than your menu?
Is your reflection code throwing an exception, and are you ignoring it?
Is your reflection code actually being called? Toss a println() in there to be sure!
Is the test for the interface suffering from a typo or similar error that's causing it to fail? Try finding classes that implement Serializable instead!
Is your reflection test running in the main thread and trying to update your GUI? You need to use SwingUtilities.invokeAndWait to get an update to the Swing worker thread.
You're working with Eclipse; Eclipse has a fantastic debugger. Set a breakpoint near where your main action is and then single step through the code.
PATH and JAVA_HOME won't help. PATH only affects dynamically-linked libraries ("native code"). JAVA_HOME is a scripting variable that happens to be used by some Java-based utilities like Ant and Tomcat; it means nothing to the Java runtime itself.
You need to be investigating the classpath, which should be specified by the -classpath option to the java command, in the Build Path in your Eclipse project properties, or in the Class-Path attribute of the main section of a JAR file if you're launching java with the -jar option.
From within your code, you should be able to list the contents of your classpath by examining the system property, "java.class.path"
System.out.println(System.getProperty("java.class.path"));
Problem solution:
Classpath leading to source code must have no spaces in it.
I am running windows XP and, for whatever reason, if the classpath that leads to the jar file or source code that is using reflection has any spaces in it, then the reflection fails.
I took the jar file that works for the rest of my team and ran it from C:\ on my system and the reflection worked perfectly fine.
I do not know why this is so please comment if you know what is happening.
Might be a long shot, but look for differences in security settings for you and your team mates. Article describing more details http://www.ibm.com/developerworks/library/j-dyn0603/ heading "Security and reflection"
I'm trying to make a small GUI app and I want to use MigLayout with it.
As Java newbie I don't know how to get MigLayout to work with my code and I'm running out of ideas.
My project source code is in ~/git/project/src/qdb/
The qdb is my java package name. I downloaded miglayout-3.7-swing.jar and miglayout-3.7.jar and placed them to my project sources and tried to compile the code but I get errors pointing to "new MigLayout()" stating "cannot find symbol".
I was in src dir and used "javac qdb/*.java" to compile (* gets expanded).
I also tried to point classpath to my sources like: "javac -classpath /home/user/git/project/src/qdb/ qdb/*.java" but I still get the error.
Then I've also tried to put the jar files to ~/jars/ and use that as classpath but still the same error follows.
So, how to get MigLayout working?
Simply add the miglayout-3.7-swing.jar to your classpath:
javac -classpath /your/path/to/miglayout-3.7-swing.jar qdb/*.java
(as illustrating in this thread Installing Mig Layout)
If you can compile them (with the above line),
but can not execute the resulting program, you also need to add to the java classpath the library
java -classpath /your/path/to/miglayout-3.7-swing.jar:/your/project/compiledClass/dir qdb.yourMainClass
If you are going to put it into a .jar file, you'll need to specify the Class-Path in the manifest file:
Class-Path: /your/path/to/miglayout.jar
VonC's answer is right. I just want to add (since you are a Java newbie) that you should consider developing using an IDE. They'll save you hours of by-hand-compiling, and will help you integrate your code with libraries (such as MigLayout) more easily.
There are two free IDEs I really like:
IBM's Eclipse.
SUN's (soon to be IBM's) Netbeans.
Also consider this SO thread. And this one too.
Good luck.