I'm trying to port a Swing application to GWT.
However lots of this application classes use things that are not supported by GWT JRE emulation library such as java.util.Locale, java.text.SimpleDateFormat and much more.
Is there a tool that scans a project and spots such problems?
The Google Plugin for Eclipse shows errors for things that are unsupported by GWT's JRE emulation. http://code.google.com/eclipse/
The GWT compiler will complain if you try to access classes in the JRE that are not supported.
My GWT plugin does not warn until the end of a compilation process.
I fixed this issue by the following way.
In eclipse,
Create a java project.
Remove JRE from class path.
Go to gwt-user.jar. Locate java emulation classes. The path is like that: ..super../emul/java/...
Copy them to your java project.
What we get So far, your Java project without JRE have java.lan. and etc. classes.
This will work except com.google.gwt.lang.Array.java will be missing.
I created that array class (you can find it from internet, I couldn't locate it inside jars).
Add gwt-user and dev jars to the classpath.
Now, your own library can use only gwt java emulation and other gwt classes.
Eclipse will automatically warn you if you access a non emulated Java library.
Related
We want to use both SWT and JavaFX in an Eclipse plugin within our RCP application. Unfortunately, we're experiencing problems integrating SWT with JavaFX under Java 11. The build environment uses e(fx)clipse 3.5. We're developing against the Community edition of Azul Systems' "Zulu" JDK 11, bundled with Azul's version of OpenJFX.
Formerly, we developed under Java 8. At that point, our build used a compile-time class path referring to jfxswt.jar, which lived in the jre/lib directory of the JDK. We didn't use any special class path settings at run-time.
We are now trying to move to Java 11. There, this JAR has become javafx-swt.jar and lives in the lib directory of the JDK. It no longer seems to be enough to set the class path to refer to this JAR at compile time: it seems to be necessary to do so at run time too. If we don't do this, we get an error (java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas).
As a test, we experimentally embedded javafx-swt.jar within the JAR implementing our Eclipse plugin. We then referred to it in that plugin's .classpath file, and the code worked as expected. Unfortunately, we can't embed the JAR this way for legal and other reasons.
A note on Java modules: javafx.swt does not show up in the output when we issue the --list-module command. We tried running the application using parameters -p /path/to/JDK/lib/javafx-swt.jar --add-modules javafx.swt, but this doesn't seem to solve the problem.
My question: Is there a way to set up the class or module path to allow our Eclipse plugin to find this library in the JRE? Any solution would have to work with whatever JRE the code happens to be run against (I think it is all right to assume lib/javafx-swt.jar will live in that JRE).
Would it help to use a separately-downloaded version of OpenJFX rather than the copy of OpenJFX in our JDK?
Very many thanks ☺
I want to use some javax annotation on a GWT app. I download javax.ws.rs-api-2.0.jar here, and then include it in my project (Project/Properties/Java Build Path/Libraries/Add External Jars).
I clean my project, then I refresh my project and build it. But when I launch the Run as button, I got following error:
[ERROR] [gwtinit] - Line 5: The import javax.ws cannot be resolved
Eclipse show me no error in my source file, what did I miss?
With GWT you cannot use all Java libraries available for server side Java. You are restricted to a small JRE emulation subset.
As a consequence you cannot use any librariy using standard Java classes outside of the emulation subset.
Often there are special GWT libraries for the same purpose.
You don't get an error in eclipse because Eclipse interprets your code as standard Java. It doesn't know anything of the GWT restrictions. This is a common pitfall for everbody new to GWT.
Right now I'm trying to get Java3D to work with JDK 1.8.0 in Eclipse on OS X. I've tried following this tutorial (among many others) and am finding varying levels of no success. I believe part of the problem is that there are currently 3 separate locations with the Java3D .jars are ending up on the build path:
/Library/Java/Extensions/ as a part of the JRE system library
/System/Library/Java/Extensions/ as a part of the JRE system library
My personal libraries folder as external included .jar files
Earlier in project development, I hadn't updated the files in the Library folders (they were whatever came with the Mac), and in that case there were no Eclipse errors, but the project could not be run (UnsatisfiedLinkError: no j3dcore-ogl in java.library.path)
Now that I've updated both of the JRE system library .jar files, the code has errors: Access restriction: The type '...' is not API (restriction on required library '/Library/Java/Extensions/j3dcore.jar')
What's the proper way to clean up all these locations so that the project only references one set of these .jars, and where should these .jar's be?
There is only one way to clean up: uninstall all those obsolete versions of Java3D provided by Apple ("whatever came with the Mac") and follow my instructions.
The extension mechanism has been removed from Java 1.9, relying on it is a very bad idea. Only use a carefully chosen "personal libraries folder" whose scope affects only your application and not the rest of the operating system.
If you need some help on Java3D, rather use its official forum.
Back in the old times, the Sun Java dev. toolkit (v2.x) used to have a stub generator tool, but no longer in 3.x versions. I can still use the old generator, but it is very picky when it comes to input WSDL files, and the errors generated do not contain any useful info to fix the WSDLs. The company that develops the SOAP WS is providing me with WSDLs not compatible with JSR-172, and I need to prove I'm using the the last official tool available to show there's no problem on our side.
I have installed the last reliable version of JavaME SDK (3.4) available at Oracle's site. These 3.x versions do not include an IDE, instead they provide plugins for Netbeans and Eclipse. I'm an Eclipse person, but I've opted for the Netbeans approach because looks easier to configure.
So I've downloaded the last Netbeans version (7.4). I've downloaded the bare-minimum JavaSE only version, then installed the mobility plugin for JavaME (Last time I needed to install Netbeans, you had to install the full JavaEE IDE plus GlashFish servers, etc. So glad to know they now offer the option not to install the full IDE).
Added the JavaME SDK v3.4 in platforms, but it does not detect it automatically. I was forced to configure a custom platform, but then the ant build failed. To solve this, I've installed the JavaME SDK v3.2 as well, which is detected by Netbeans out-of-the-box and builds fine.
You might think the stub generator tool would be available by now. Wrong!. You still have to go and install the "SOAP Web Services" netbeans plugin, which in turn installs a ton of other dependent plugins (by now the lightweight JavaSE install has become the bloated JavaEE-ready IDE that Netbeans has always been).
So then I created a basic JavaME project. Right-clicked over Source packages, then selected "New" -> "Java ME Web Services Client". The stub generator dialog is finally shown (and it looks pretty much like the old Sun Java CLDC 2.5.2 tool). I select the WSDL input file, type the client name and package name, and also ticked the "Generate databindings structures" checkbox (which I don't know what the heck it is for, but suffice to say I've tried both w/ and w/o this option selected and the result is the same).
Then I click the Finish button and only a .wsclient file (along with the imported wsdl file) is created. What is the purpose of this file? But most importantly, where are the .java or .class files? They are nowhere in the project folder!
Questions:
Is it possible to generate JSR-172 stubs using Netbeans?
If not, is it possible to do this using the Eclipse JavaME plugin?
It turns out there is a problem with the input WSDLs. They are valid but something is wrong because Netbeans does not generate any java file.
I've tested again with a known good WSDL and it works, so the procedure I followed is correct.
UPDATE:
I was using a local WSDL input file, and due to a bug in the SDK, if the file path contains whitespaces, the stub generation fails. In NetBeans no error is shown.
I've started encountering some weird exceptions trying to use the GWT designer. I'm on Ubuntu if it matters, GWT 2.4.0, Java 1.6.0_20 x64
When I use the designer, a previously used DisclosurePanel shows up in a pink box indicating. When viewing the details, it indicates a NoClassDefFound error. This makes no sense because in the code editor, the class is visible and compiles without error.
Secondly, I am unable to drop a CellTable instance on the designer. Even with the most basic T = java.lang.Object, the error comes back indicating an IllegalArgumentException : "Unable to find 'columns' in class com.google.gwt.user.client.UI.HTML.
This was working yesterday with the designer, but all of a sudden has entered the crapper. I tried reinstalling the GWT plugins, and even using a new eclipse install with fresh GWT plugins installed, but to no avail. Does anyone know the source of these errors and how to remedy them?
Alright, it seems that the other day I synced up my build machine for the fisrt time and had a different version of java installed on my dev machine. OpenJDK 1.6.0_20 (Iced Tea 1.9), vs Java SE 1.6.0_35.
Since this java was in my /usr/bin which was earlier in my PATH envi var than my 1.6.0_35 build that was at the end of the PATH, it was using hte older 0_20 version. I'm guessing the GWT designer was built with something closer to 1.6.0_35 than 1.6.0_20, and was causing conflicts as implied here.:
Start by checking your Eclipse ".log" file (found in your /.metadata directory). If the error references one of your classes or methods, check that your classpath properly references the class you are trying to use. Also check that your class is properly compiled (no red X's) and that a .class file exists in your projects /bin directory. A mismatch between the JDK used to compile your code and the JVM used to run Eclipse can also manifest itself as a NoClassDefFoundError problem. For example, if you compile your code using JDK 1.5 or 1.6 and then run your Eclipse using a 1.4 or 1.5 JVM, you can have this problem. If the error refers to a custom widget, you should also check that your component does not trigger an exception during its initialization (which can manifest itself as a NoClassDefFoundError). Try refreshing and cleaning your project using the Project > Clean... or Project > Build Project commands. If that does not help, send a test case to support.