How to get Javadoc to include documentation for a sub-project? - java

I have two projects in Netbeans that are closely linked. They are separate projects because one of the projects is a util package that could be used in the future for another project. Is there a way to configure Netbeans so that the Javadoc generated for the main project will include links to the objects defined in the util project instead of listing the full package path?
Edit: I have found how to do it. In Project Properties > Build > Documenting you can set Additional Javadoc Options. The option to use is -link and then the URL of the documentation directory. However, I can only get it to work with an absolute link and am having trouble getting the relative link to work.
-link file:///A:\B\C\Util\dist\javadoc //this works
-link file: ..\..\..\Util\dist\javadoc //this doesn't works
Both project folders are in directory C, so I think that should be the correct relative path based on the documentation.

I realize that this suggestion lies outside of the implied constraints of your question, but it might be better to use an SCM tool (and not your IDE) to publish javadoc that covers dependent projects. For example, Maven has a plugin specifically designed to publish javadoc for modular projects.

Related

Unable to launch a java/javaFX code after a clone on IntelliJ

It's very complicated to explain so sorry if it's not clear. Basically, I'm on a group project in javaFX, and every time I clone it, my PC doesn't recognize either Java or JavaFX on THAT project exactly. All the others work fine. So I have to do a lot of manipulation each time for it to "work" (I explain below).
And today I have clone because of an error. Except that impossible to make it work again.
What I did on IntelliJ after cloning:
-I reloaded the MAVEN project
-I imported the java libraries
-I put the right folder in ROOT
-I created the configuration
From there, Java and JavaFX are recognized. After that, I have other problems. In particular that of "The output path is not specified for module structure" and after that it redirects me to File -> Project Structure -> Project and compile output. Except that in my previous problems, I didn't have to define a Compiler Output. Usually the steps above were enough. And the problem is that I have no idea what to put in this section. I searched all over the internet, but 90% of the time it's an old version of IntelliJ and it was asking them for a path. There, I am asked for a file (impossible to choose a destination path, it is greyed out). And in CTRL C + V the path directly (for example an excluded "Out" folder like what I have read on the internet), I have this error at launch:
Error occurred during initialization of boot layer java.lang.module .FindException: Module start.structure not found
I want to re-specify that there is no error in the code, we have exactly the same with my team, and with them it works without worries.
If someone know how to resolve theses problems
This isn't really fully answerable here in a general sense, because there are too many environmental and project-specific things that may occur.
Instead, I'll provide a suggested approach for a new project:
Create a new JavaFX project in Idea.
Choose Maven for the build tool.
Follow the execution instructions from the linked documentation to ensure the project runs in your environment.
Share your new JavaFX project on GitHub.
Clone the newly shared project to a new Idea project.
This is emulating somebody else checking out the project from GitHub.
Run the newly checked out project in your Idea environment exactly as you did for Step 1.
That is really all you need to do to use JavaFX + Idea + GitHub.
A pre-existing project may require additional steps for configuration and use which may be project specific, so I can't generally advise on that.
Some comments on the approach outlined in your question:
You mention "every time I clone it".
You only really need to clone a project once, after that you can just update it.
The image has a folder ${project.build.directory}.
That looks wrong, kind of like an expansion variable name was applied literally rather than being expanded (I don't know what you did to cause that).
Your resources folder isn't marked with a resources icon.
This indicates that you haven't imported the project from Maven correctly.
Normally Idea will recognize a Maven project and import it automatically, mapping the standard directory structure, e.g. src/main/java is Java source and src/main/resources are resources.
"I have put the right folder in ROOT"
I am not sure what that means, but it should not be necessary to manually configure things like this. As mentioned, Idea knows the standard Maven project structure and is able to apply it without manual intervention.
"I created a configuration."
You don't need to create configuration manually.
The configuration you have created is wrong.
If you right-click on your JavaFX application class and choose run, an appropriate run configuration for the application will be created automatically.
The configuration does not need to specify a JavaFX SDK.
You don't need to (and should not for this purpose), install a JavaFX SDK on your machine.
The configuration does not need to specify a module path or modules to add.
Idea and Maven are smart enough to know that:
your application is modular (because you have provided a module-info.java)
the required modules are provided as Maven dependencies (this includes the JavaFX modules that you need)
the modules should be placed on the modulepath (Idea and Maven will do this automatically, you don't need to do anything manual for this to occur).
For the message "The output path is not specified for module structure":
I don't know what this means, but, if you follow the suggested approach, you don't need to manually specify an output path, Idea and Maven will automatically assign appropriate values and use them without user intervention.
"Error occurred during initialization of boot layer java.lang.module .FindException: Module start.structure not found"
This indicates that you have specified somewhere that a module start.structure should be used and either:
Your application's module (specified in its module-info.java) is defined using a different name.
Your application's source code is not on the module path (perhaps it is mistakenly on the classpath instead).
Your apps module isn't correctly added.
Usually Idea will be smart enough to know that you have a module-info.java and therefore to place your application code on the modulepath, so you don't need to manually specify modulepath and add-modules options to find your application's module.

No source code is available for type com.google.gwt.ajaxloader.client.AjaxLoader;

I am migrating an project someone else built to newer packages and I have traced the root of my errors to this
No source code is available for type com.google.gwt.ajaxloader.client.AjaxLoader; did you forget to inherit a required module?
I am new to GWT and not really sure how it works 100% under the hood so I am having trouble applying solutions to similar posts to solve this error.
go to Maven Repository and get gwt-ajaxloader.jar - it contains both .java and .class files
save the jar to war/WEB-INF/lib folder in your project
right-click on the file in Project Explorer (I assume you use Eclipse), select Build Path -> Add to Build Path
enjoy ;)
GWT needs source code as opposed to .class files to do its work.
So any references you might have from your client code towards any jars, etc, need to also include source code.
In your case, you either need the source of com.google.gwt.ajaxloader.client.AjaxLoader, or remove any references towards the mentioned class, from your GWT code.

proper way to configure a project in eclipse for eSWT?

can someone direct me on how to configure a project in eclipse so that i can utilise eSWT.
Just by manually adding eswt-converged.jar gives me build/pre verification errors.
I downloaded this and utilised the jar from the folder and copied it to my project folder and added it to the build path.But it shows me something like
Please help.
EDIT
i did what Neil said and i am getting this now:
I see that in the link you provided, there are a number of other jars that I don't see included in your project. If I had to take a guess, your jar is heavily dependent on these jars which aren't there, so all the classes that it uses which are defined in these jars simply aren't there.
Though, without further information on the nature of the problem, it's difficult to determine anything else I'm afraid.

how do I add open source API code to an eclipse project?

I have to write a java application which I'm putting together using eclipse and it relies on open source code. This application needs to be self-contained, meaning that I'm supposed to create a jar file that has no external dependencies.
I can use the open source code when I reference the jar files in the project's build path, but the idea is to have the actual source code as part of the eclipse project, side-by-side with my code.
The source code can be found here: http://hc.apache.org/, but when I import an existing file system into my project I can't quite get things to work. The packages end up with the wrong names, breaking references, and I can't do anything. Notice that the folder containing the source code has this structure:
httpcomponents-client-4.2.3\
src\
httpmime\
httpclient-osgi
httpclient-contrib
httpclient-cache
httpclient-benchmark
httpclient
fluent-hc
each of those subfolders has src/main/java/org/apache subfolders.
Can someone please explain how to do this? Am I supposed to import everything one java file at a time?
Use a tool like OneJar, FatJar, JarJar, etc. to create a single-jar application.
As Charlie mentioned, the Maven Shade plugin is another choice, particularly if you're already using Maven. If you're not, consider it or another transitive dependency management tool.
Some tool should be used, IMO, and it's more important the more dependencies you have.
Alternatively you could use a jar class loader and include the jar file in your artifact.
I would most definitely not include the source of dependencies in your own project.

Tool to remove unnecessary dependencies in a Java project

I have a Java project that currently has a lot of JARs in its libraries directory, which are all included in the resulting package when building. I know, however, that some of these libs are never referenced in the project.
Is there a tool that can search for libs that are not referenced within the project? I guess there must be something in that sense.
BTW, an Eclipse plugin would be awesome.
EDIT: I chose to go with ClassDep because it was the only suggestion that worked. However, I'm having some trouble with it: please check this question
Beware of the case that a class is loaded via Class.forName() and not specified as a dependency in the manifest file (there is a Depends-On: attribute that is for that, but many people don't specify it, which breaks tools like this, the bane of my existence when I worked on such a tool).
ClassDep (from Sun, in the Jini development kit) will do this for you.
ClassPathHelper can help you with that.
Espacially the "Not on Classpath View"
This view scans for jars that are not on the classpath (but are under the current project). It provides basic browsing of packages and classes that are available but not on the classpath. This can be helpful when trying to build up a classpath, as you can quickly browse for the missing classes to see which jars contain them.
Not an eclipse plugin, but I believe the "shrinking" functionality of ProGuard is exactly what you're looking for.
I wrote a small eclipse plugin that takes an existing java project from the workspace. For every classpath entry of the projects raw classpath it removes it from the projects raw classpath and builds the project. If no problem markers with severity error appear on the project, it permanently removes the classpath entry from projects raw classpath.
I'm not able to share that plugin, but that is not too much work to implement it yourself with the links to the api given above.
You also can't tell if JARs that you don't import are required dependencies of dependencies. For example, if you use Spring it comes with its own dependencies, even if you don't import or call those classes in your code. I'm ignorant of ProGuard - does it check for those cases?

Categories