I'm having trouble getting javadoc to reference another project's API.
There's a strict hirearchy between the projects (a "common" project referenced by an "app" project).
Both projects build just fine, so there's no issue with classes and packages not actually existing.
My understanding is that javadoc doesn't have a sort of buildpath in the same way that Java does, but uses links to other javadoc websites instead. There's some pretty logical reasons for this in terms of being able to generate HTML cross references.
My attempt to make this goes as follows:
I've built the javadoc for the common project
I threw that on a webserver on my intranet
I added a link to the api (on my intranet) to the javadoc ant task in the app project.
I attempted to build the app project
Javadoc still spits out error messages of the form:
[javadoc] C:\Users\couling\workspace\app\src\com\blahblah\app\AppMain.java:14: package com.blahblah.common.foo does not exist
[javadoc] import com.blahblah.common.foo.Bar
[javadoc] ^
The resulting javadoc has no cross links between the projects.
The ant tasks for the two projects are as follows:
Common:
<javadoc
access="protected"
author="true"
classpath="."
destdir="out/doc/docs"
nodeprecated="false"
nodeprecatedlist="false"
noindex="false"
nonavbar="false"
notree="false"
packagenames="*"
source="1.6"
sourcepath="src"
splitindex="true"
use="true"
version="true">
<link href="http://download.oracle.com/javase/6/docs/api/" />
</javadoc>
App:
<javadoc
access="protected"
author="true"
classpath="."
destdir="out/doc/docs"
nodeprecated="false"
nodeprecatedlist="false"
noindex="false"
nonavbar="false"
notree="false"
packagenames="com.blahblah.app.*"
source="1.6"
sourcepath="src"
splitindex="true"
use="true"
version="true">
<link href="http://intranet.blahblah.com/api/common/docs/" />
<link href="http://download.oracle.com/javase/6/docs/api/" />
</javadoc>
Any thoughts on what I need to do to get app to reference common?
The <link> element (or the -link option for command line javadoc) only help with generating the links - but Javadoc stops at an earlier point, it can't really work with your app classes if they reference unknown (common) classes.
In this respect, Javadoc works just like Javac - you must somehow point it to the classes to be used, i.e. they must be in the class path. You can use a <classpath> element to point to the jar file or class directory, or a <sourcepath> element, to point to the sources (do this if you need to inherit some comments from them).
This is not needed for linking to the standard API, since it is already included in the compiler.
Note that linking in this way requires Javadoc to download the package-list from this URL - you can instead point to a local directory which contains this package-list file.
Related
I'm trying to build soot.
I've downloaded the source code of JastAddExtensions using svn co https://svn.sable.mcgill.ca/abc/trunk/JastAddExtensions/, checked out the code of Soot using
git remote add soot https://github.com/Sable/soot.git
git pull soot develop.
Then I tried to build Soot using Ant and got following error message:
D:\dev\ro-01\soot\build.xml:102: The following error occurred while executing this line:
D:\dev\ro-01\JastAddExtensions\SootJastAddJ\build.xml:18: taskdef class JFlex.anttask.JFlexTask cannot be found
using the classloader AntClassLoader[]
How can I fix this error? Where can I download a version of code of JastAddExtensions\SootJastAddJ, which is compatible with current version of Soot?
You will get help faster on the Soot mailing list. You do not need do build the JastAdd part of Soot. It's pre-built in the directory "generated".
Check out:
http://jflex.de/jflex_anttask.html
Simple answer: You probably haven’t copied the JFlex jar to ant’s library folder/directory.
If that doesn’t straighten you out… More complex solution: Find the soot Ant file, probably in the project root directory as build.xml.
Then find a task definition named “jflex” that probably looks like this:
<taskdef classname="jflex.anttask.JFlexTask" name="jflex" />
Change it to something like this:
<taskdef
name="jflex"
classname="jflex.anttask.JFlexTask"
classpath="${compiler_tools_path}${jflex_jar_name}"
/>
Up near the beginning, with the other properties, create a new one with the location of a directory/folder you create and copy the latest JFlex jar to:
<property
name="compiler_tools_path"
value="/Library/CompilerTools/"
/>
This is an appropriate place to create a directory/folder to store this on a Mac. Windows and Unix, anywhere externally installed jars are stored.
<property
name="jflex_jar_name"
value="jflex-1.5.1.jar"
/>
An example of a recent JFlex jar build. Check out:
http://jflex.de/
I hope this was helpful.
Jeff
I took a look at build.xml in the soot repository. The problem is with the target jastadd. The JustAdd compiler uses Beaver as its parser generator, which also requires JFlex as it's scanner generator for handling .flex files.
Just follow my simple solution mentioned previously. Make sure you rename the jflex-1.5.1.jar file that you copy to Ant's lib directory to "JFlex.jar" It's all in the document I gave you that first link to.
I'm answering this problem so late because I only just came across a similar problem with getting ant files to work with JFlex in Eclipse projects.
Jeff
I recently tried packaging a Java app for distribution in the Mac App Store, but discovered that by bundling the default JRE, the app increased its file size by about 138 MB. I would like to reduce the size of the JRE by stripping out components that I don't need (e.g. Corba, JavaFX, XML parsing), thus resulting in a smaller increase when I bundle it into an app.
There are a couple of questions, like this one, that give some guidelines about what components to remove, but none that actually describe how to go about reducing it. What do I need to do to reduce the size of the JRE? Are there certain tools? Do I just download the source and hack out the classes I don't want? Do I edit my currently installed JRE? I'm not really sure where to begin.
I havent tested this myself but after some searching heres what I have found.
The Packaging a Java App for Distribution on a Mac guide gives you a basic look at how to bundle the app (which it sounds like you got already). From there I followed the docs for app bundler, on that page under "runtime" you see you can explicitly include or exclude files/folders from the bundling.
According to their docs
"By default, only the contents of the jre/ directory will be included with the bundled application. All executable content (i.e. bin/, jre/bin/) is excluded. Additional content can be included or excluded using nested <include> and <exclude> elements, respectively."
From that I took their sample code and added an exclude statement:
<-- Import environment variables -->
<property environment="env"/>
<-- Define the appbundler task -->
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask"/>
<-- Create the app bundle -->
<target name="bundle-swingset" depends="package">
<bundleapp outputdirectory="."
name="Test"
displayname="Test"
identifier="com.oracle.javafx.swing.Test"
shortversion="1.0"
applicationCategory="public.app-category.developer-tools"
mainclassname="com/javafx/main/Main">
<runtime dir="${env.JAVA_HOME}">
<exclude name="Java IDL Server Tool" /> <!-- exclude from bundle -->
</runtime>
<classpath file="${user.home}/bin/javafx-samples-2.2.0/SwingInterop.jar"/>
<option value="-Dapple.laf.useScreenMenuBar=true"/>
</bundleapp>
</target>
A full list of optional excludes can be found in the JRE root - $JAVA_HOME/README.txt. Do a find for the text Optional Files and Directories and you'll be at the header of it. I am looking at the JRE7 installation on my computer, the JRE6 readme didnt seem to have anything in it.
I know this isn't working the example you're looking for but I hope it helps you figure it out.
We got a GWT project in Eclipse, that otherwise works.
Now I want to have a script that runs on the server, which pulls the latest version from source control and compiles it on the server and deploys it.
This will save us a lot of manual work and allow us to deploy new version when on a connection with limited bandwidth (since we won't have to upload the application to the server).
After pulling the latest version of the source code, the script tries to compile the code using the following command:
java -cp "/path/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201211121240-rel-r42/gwt-2.5.0/*:/path/company/projects/pull-compile-deploy/X/X/src:/path/company/projects/pull-compile-deploy/X/X/war/WEB-INF/lib/*" com.google.gwt.dev.Compiler nl.company.projects.X
Compiling module nl.company.projects.X
Finding entry point classes
[ERROR] Unable to find type 'nl.company.projects.X.client.XMain'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
All source code is in /path/company/projects/pull-compile-deploy/X/X/src and all used .jars (except for the GWT stuff) are in /path/company/projects/pull-compile-deploy/X/X/war/WEB-INF/lib/. Obviously something goes wrong.
Questions: The file /path/company/projects/pull-compile-deploy/X/X/src/nl/company/projects/X/client/XMain.java does exist and should imho be in the classpath?!
Anyone Any idea what might go wrong here?
Is it maybe possible to see in some log exactly the commands that eclipse executes for compilation? I looked at the build.xml that eclipse can export, but it seems that does not contain a target to compile for production.
something else: apperantly GWT expects the X.gwt.xml to be at /path/company/projects/pull-compile-deploy/X/X/src/nl/company/project/X.gwt.xml, whereas eclipse put it in /path/company/projects/pull-compile-deploy/X/X/src/nl/company/project/X/X.gwt.xml (i.e. nested one directory deeper), I fixed this by creating a symbolic link.
Further Edit:
Since one answer focused on how I invoked the compilation tools, I have rewritten that in Ant, see below.
The problem remains of course.
<!-- Compile the source using javac. -->
<target name="compile" depends="init">
<javac srcdir="src/" destdir="bin/">
<classpath refid="project.classpath"/>
</javac>
</target>
<!-- Use the GWT-compiler. -->
<target name="gwt-compile" depends="compile">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<path refid="project.classpath"/>
<pathelement location="src/"/>
<pathelement location="bin/"/>
</classpath>
<jvmarg value="-Xmx512M"/>
<arg value="${module.name}"/>
</java>
</target>
Anything wrong with the above Ant-script?
module.name = nl.company.projects.X and the path with refid="project.classpath" contains all used libraries aswell as the GWT libraries (gwt-user.jar, gwt-dev.jar and validation-api-1.0.0.GA(-source).jar).
The XMain class inherits nothing (other than from Object) and only implements EntryPoint (which is included in the gwt-user.jar). So I do not think the problem is related to the second hint that the compiler gives.
Any ideas?
GWT requires you to javac your classes, it needs both the *.java and the *.class files.
This has not always been the case, and should change back in the future (see https://code.google.com/p/google-web-toolkit/issues/detail?id=7602 for instance), but for now that's the state of affair: you need to javac before you can com.google.gwt.dev.Compiler.
javac -cp "/path/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201211121240-rel-r42/gwt-2.5.0/*:/path/company/projects/pull-compile-deploy/X/X/war/WEB-INF/lib/*" -sourcepath /path/company/projects/pull-compile-deploy/X/X/src /path/company/projects/pull-compile-deploy/X/X/src/nl/company/projects/X.java -d /path/company/projects/pull-compile-deploy/X/X/bin
java -cp "/path/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201211121240-rel-r42/gwt-2.5.0/*:/path/company/projects/pull-compile-deploy/X/X/src:/path/company/projects/pull-compile-deploy/X/X/bin:/path/company/projects/pull-compile-deploy/X/X/war/WEB-INF/lib/*" com.google.gwt.dev.Compiler nl.company.projects.X
(please double-check the above commands before use)
EDIT: (in response to your "question" re. the X.gwt.xml): GWT expects the X.gwt.xml at nl/company/projects/X.gwt.xml because that's what you told it to use: module.name = nl.company.projects.x. If the file is at nl/company/projects/X/X.gt.xml then use nl.company.projects.X.X as the module name. Using a symbolic link here is likely to be the problem: the source path for the module (search for <source at https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideModuleXml) will then be nl/company/projects/client and thus won't include nl/company/projects/X/client where your XMain class lives; it's this unavailable to the GWT compiler.
That said, I totally agree with SSR: use a decent build tool: Ant, Maven, Gradle, Make, whatever, it'll make your life so much easier. A build tool that manages dependencies (Ant+Ivy, Maven, Gradle) is even better IMO.
Why would you put yourself through such non-standard build exercise like this.
If it is non-academic project then USE maven. If you find maven difficult then use ant.
Examples for both type are provided by GWT team - http://code.google.com/p/google-web-toolkit/source/browse/#svn%2Ftrunk%2Fsamples.
Note - maven has plugins to do most of the stuff you are trying in standardized way.
I'm trying to get some server side stuff going for my GWT project. As a test I tried to add in a com.sun.jmx.snmp.SnmpOid object which isn't supported by GWT run-time into my GreetingServiceImpl.java (a file that gets generated with every GWT project), but it's still saying that it's not supported.
I did the RPC GWT tutorial and when I copied the same code into that projects GreetingServiceImpl it worked fine.
I feel that I'm missing a reference or a line in an XML file. I've compared both projects thoroughly but couldn't find any discrepancies.
Any help would be appreciated.
Exact Error: com.sun.jmx.snmp.SnmpOid is not supported by Google App Engine's Java runtime environment
Please check the source path in your .gwt.xml file. It should say something like:
<source path='client' />
<source path='shared' />
Make sure, that your GreetingServiceImpl isn't in the source path.
If that's not the problem, please provide the exact error message you get.
Update
The error message you provided now, indicates that the class isn't supported by AppEngine - that's not the same as "not supported by GWT". If you don't need AppEngine, remove AppEngine support from your project (Project > Properties > Google > AppEngine > Use App Engine).
I want to develop a web application (no frameworks) mixing java with groovy. I am using the IDE Netbeans with the plugin.
If I start a new Java SE project and add a groovy class, it works with no problems.. but when I create a new java EE project and add a groovy class it can't compile and shows me the following error:
/home/webcodei/NetBeansProjects/testeGroovyWeb/src/java/pacote/Hello.java:23: cannot find symbol
symbol : class Hroovy
location: class pacote.Hello
Hroovy h = new Hroovy();
/home/webcodei/NetBeansProjects/testeGroovyWeb/src/java/pacote/Hello.java:23: cannot find symbol
symbol : class Hroovy
location: class pacote.Hello
Hroovy h = new Hroovy();
2 errors
/home/webcodei/NetBeansProjects/testeGroovyWeb/nbproject/build-impl.xml:383: The following error occurred while executing this line:
/home/webcodei/NetBeansProjects/testeGroovyWeb/nbproject/build-impl.xml:211: Compile failed; see the compiler error output for details.
FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)
Does anybody have a clue of how do I enable Java EE + Groovy in netbeans?
ps: I know the existence of Grails
ps2: The Groovy jar is in my classpath.
Thank you for all!
It appears that the NetBeans 6.5 Java Webapp project manager does not have the "Enable Groovy" support that is present in the Java App and Java Class library projects.
I can think of two ways you might get around this:
First, you could put your Groovy code and tests in a separate project as a Java Class Library. Then make the Java webapp dependent on the Groovy project. NetBeans will build the dependent project automatically so you'll hardly notice they are in separate projects.
Second, the "Enable Groovy" isn't magic. All it does is write a groovy-build.xml in /nbprojects and modify build-impl.xml to import it. The groovy-build.xml overrides the default "javac" macro to invoke "groovyc" instead. If you're at all handy with Ant, you could copy a groovy-build.xml from a Java Application project and copy it to your Java Web project and then import it from your build.xml (before build-impl.xml is imported). The groovy-build.xml would likely need a few tweaks as some of the properties between a webapp and class library are a little different.
#Dave Smith,
This was exactly what I did. I created one javase project and one webapp and started to compare them. After a few minutes I realised that the only diference was the groovy-build.xml.
So I copied the groovy-build.xml into the dir, and inserted the following lines into my build.xml:
<import file="nbproject/groovy-build.xml"/>
Right before the regular
<import file="nbproject/build-impl.xml"/>
And then called the groovy file to overwrite the -init-macrodef-javac.
<target depends="-groovy-init-macrodef-javac" name="-pre-compile">
</target>
I also needed to change the namespace from the groovy-build.xml to mine ex:
<macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
And inserted the j2ee classpath (${j2ee.platform.classpath}) to the attribute a few lines later:
<attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
After that the project worked successfully! =D
Thank you for all!