I'm wanting to use some java code as a reusable component jar in my GWT 2.4 application.
I need access to that code on the client side, so I've read that the steps involved are to
add an entry in the main projects gwt.xml file pointing to this project,
include a gwt.xml file in the jar
and put the java code under a client folder.
I assume that this has to be a gwt project itself, otherwise there would be no need to add the inherits entry or is it not possible to use a regular java project client-side?
Is there anything else I need to do for this (other than ensure the libraries in the jar fall under the JRE Emulation Reference list)?
We don't use the plugin functionality in Eclipse, but to use another project in your GWT project all you need to do is define a .gwt.xml module file in your project that you want to use in your GWT project and reference that module file with <inherits.../> in your main GWT project. You will also obviously need to add that project as a reference in the build path in Eclipse, so you don't get compilation errors. And all of that is besides the fact that your referenced project has to comply to the JRE emulation reference so it can be fully GWT compilable.
Related
Just recently started using Eclipse and ran into an issue with exporting the plugin I'm working on. I tried to search but so far no luck - but if the answer is already here I'd be grateful if someone can point me to it.
I'm writing a n OSGi/Equinox plugin with Eclipse. The plugin is for a 3rd party system, which allows extensions: basically all jars placed in the application's plugin folder are automatically loaded into the application at startup. I have managed to put together my plugin, it's loading fine and it works.
The issue is that I rely on another plugin which is placed beside mine in the plugins folder. For obvious reasons I do not want to package that plugin into my plugin jar file. I have tried to add the dependency as an external archive, but this breaks the export: when I try to export my plugin project ant complains about missing dependencies and types. (If I actually include the other jar file in my plugin everything works, but obviously this is less then ideal.)
So: how do I set up my plugin project dependency, that it's a) an external dependency and b) doesn't need to be specified with a path or a variable - i.e. how do I tell my exporter to "don't worry, it will be there right beside you"?
Edit: Apparently there's an important detail I didn't mention. The external jar file I depend on is not an OSGi plugin, just a regular jar file with some classes in it. To the 3rd party system it seems all the same (all are under the plugins folder, all are loaded into the application), but for Eclipse the distinction seems important.
If you reference the other plug-in as a dependency in your plug-in's MANIFEST.MF the export should work without errors. The plug-in should be listed in the Require-Bundle list in the MANIFEST.MF.
You can do this in the MANIFEST.MF editor by adding to the 'Required Plug-ins' list on the 'Dependencies' tab of the editor.
Note: When referencing other plug-ins you must always use this method. Do not try adding the plug-in jar to the Java build path or anything like that.
If the jar you want to use is not an Eclipse plug-in you must should include it as part of the plug-in and list the jar in the Bundle-Classpath in the MANIFEST.MF. If you cannot do this you can reference an external jar in the Bundle-Classpath using something like:
Bundle-Classpath: .,external:$LIB_LOCATION$/lib.jar
. is the normal entry in for the plug-in code. external:$LIB_LOCATION$/lib.jar looks for lib.jar in a location defined by the environment variable LIB_LOCATION. This method can be difficult to get right.
In the end the solution to my specific problem was to add the external jar file as an Extra Classpath Entry on the build properties tab (this translated to a "jars.extra.classpath = .jar" entry in the build.properties file). I have also added the jar file to the project itself - after adding the extra class path entry that got changed into an external dependency automatically.
With these two changes I was able to successfully export my plugin, which didn't contain the external jar file, but was able to reference it when loaded into the 3rd party system.
I am trying to figure out how to use external jar in GWT project.
I referred http://www.vogella.com/articles/GWTModules/article.html and it worked perfectly.
But the example explained using another project being included in the GWT project's build path instead of including the jar of that project.
I know this should not make a difference but when I created the jar of the external project (including sources) and used it in the client GWT gave me following error:
The import com.person cannot be resolved
What would be the problem?
For using external gwt library jar file in your gwt eclipse project you have to add that jar file in library tab from java build path:
If you want to use external jar and use that jar classes in your client side. you have to inherit module package entry in client gwt module.gwt.xml
Just example a. com.test.Module2.xml so you have do entry like
<inherits name='com.test.Module2'/>
I have a working GWT project library which I include to other GWT projects that need to use it. So far its been useful enough, however I need to make it a library jar, what is the process of doing it?
I tried to export the jar using File->Export->JAR File process with Eclipse however when I included the jar file in the same projects where I used to include the project file, it won't work.
Any ideas?
Make sure you package *.java along with *.class. Module gwt.xml should also be placed in correct package.
See an example here.
In eclipse export wizard, make sure "Export Java Source files and resources" checkbox is checked.
I created a module to share code across a couple of projects.
I created a GWT project: Framework. I then created a module com.framework.Framework within the project. The Framework project contains both client code, in the com.framework.client packages, and server code in the com.framework.server packages.
I try to consume this by
- Adding the project to the Java Build Path
- Adding to the module's definition
When I run the consuming project, I get NoClassDefFoundErrors for Framework classes I use in the module's server code.
What am I missing?
If I jar up the Framework project's WEB-INF\classes contents and put it into the consuming project's WEB-INF\lib folder, as well as add it to the Build Path it seems to work, but I don't see a way to keep the framework classes up to date in the consuming project(s).
Please make sure that you create gwt.xml file via menu New->Module, and in this gwt.xml file, you must declare your entry point class.
Is there a way to add a dynamic library folder to a plain Java project similar to WEB-INF/lib in a Dynamic Web Project?
I mean, can I specify a simple folder, let's just call it lib, and have Eclipse monitor it for any library jars I might want to add or remove.
Currently I only know this behaviour from the Web App Libraries where any jar you copy into WebContent/WEB-INF/lib is automatically added to the class path, but in "regular" Java Projects I need to add every jar by hand.
Yes and no. It requires writing a suitable extension to the org.eclipse.jdt.core.classpathContainerInitializer. If you're in the Package Explorer, though, you can just select all the jars within the View and use the context menu to add/remove them to/from the Java Build Path.