I want to use the latest version of org.json in my Google App Engine project. My project uses GWT plugins, which provide their own, older version of org.json, so if I put my json.jar file into WEB-INF/lib it gets ignored. If I go to the Eclipse project's Properties > Java Build Path > Libraries to remove the GWT JDK jar the project won't compile. If I use the same properties tab to add my own json.jar to the list of libraries (via Add Jars...) it doesn't help.
Is there anything I can do, or am I stuck with the older version of org.json?
EDIT: I'm not using Maven.
GWT no longer uses org.json since 2.7, so all you'd have to do is use an up-to-date version.
That said, even with GWT 2.6.1 or older, you should be able to:
compile against your more recent version of org.json by putting it above the GWT JDK in Properties > Java Build Path > Order and Export
run with your more recent version of org.json by putting into WEB-INF/lib. If that's not enough, you'll maybe have to remove gwt-servlet-deps.jar (which contains org.json classes) and replace it with validation-api-1.0.0.GA.jar. That however will only with GWT 2.6; with an even-older version you're out of luck (but 2.6.0 is almost 2 years old already, and 2.5.0 3 years old, that's an eternity at web scale)
Related
I recently migrated one of my personnal project from java 8 to java 10.
But then I ran into this warning which, as a warning hater, I had to fix.
Name of automatic module 'gson' is unstable, it is derived from the module's file name.
I checked the jar file I'm retrieving with maven and indeed, it's not a modular jar (there's no module-info.class in it).
So I checked GSON github and found out that there IS a module-info.java file for GSON.
So my questions are:
Why don't maven give me a modular jar? I find it very surprising considering modular jar can be used as regular jar when placed on the class path. Is it a maven thing?
What's the best way to retrieve a modular jar for GSON? (or even a JMOD file). Build the jar myself from github sources? Use an alternative to maven?
Additional informations:
IDE: Eclipse Photon Release (4.8.0)
JDK: 10.0.1
maven denpendency:
com.google.code.gson
gson
2.8.5
You're right, version 2.8.5 of Gson does contain a module-info but according to this issue it was in the wrong place. Although it's fixed now (1 month ago), a new release containing that fix has not yet been released.
I guess we'll have to wait.
I am in a bit of a jam.
I am working on upgrading our software to have Kettle 6.1. Specifically, we need the feature of S3FileOutput. Meanwhile, our application was already using the aws-sdk for other things.
So I am running into a problem: Pentaho Kettle requires version 1.0.something of aws-sdk. Our application, on the otherhand needs 1.9.6 of the aws-sdk.
To give more details, the feature of Kettle we require is in the pentaho-big-data-legacy plugin. Even if I upgrade to the latest version of Kettle, pentaho-big-data-legacy still uses the old version of the aws-sdk.
I've read a bit about plugins having special classloaders, so one option I was considering is that maybe I am not downloading the right dependency. However, when I tried downloading pentaho-big-data-plugin instead of pentaho-big-data-legacy, I got weird errors, so I stopped going down this path.
I was wondering if there is any way I could put the Kettle Libs in one folder, and my application libs in another folder, and then set some sort of a PENTAHO environment variable to pick up the libraries from the alternative folder.
Another option is if I could somehow set the pentaho classloader, but I don't know if this is possible.
What are my options for having 2 versions of the aws-sdk in my application, with regards to Kettle?
Maven can do much more than download dependencies.
The Maven Shade plugin can help with your current predicament. During a build, it can rename packages.
You would make a project that builds a "fat jar" (or "uber jar") with Pentaho Kettle and its version of the aws-sdk re-packaged as appropriate. That dependency would be handled before your project is built, so you are free to use whatever version of aws-sdk you like since there is no longer a conflict on package names.
I've used a 17 version of Guava for my library project and extracted it into the jar. Other project uses my library but it also has a much older version of Guava. When I try to run application, it ignores new Guava and causes errors like
java.lang.NoSuchMethodError: com.google.common.cache.CacheBuilder.maximumSize(J)Lcom/google/common/cache/CacheBuilder;
How to force my project to use a new Guava and application to use an old?
I am assuming that your project and applications are distinct entities.Also, by Project I assume that you are referring to an Eclipse/IntelliJ/Netbeans project
You would need to set the correct classpaths for the Project and your application separately.
If you are using the IDE to debug your project, your project would need to include the new JAR that you have downloaded. Each IDE has it's own mechanism for adding dependencies to the Project's classpath and hence you would want to refer to the documentation related to that IDE.
For your application you can launch it as java MyApp -cp "path to the old JAR". If you are packaging your application as a JAR, make sure you are packaging the older version of Guava.
Hope this helps.
Edit based on the discussion with the owner of the question
The query here is similar to this SO query. The right way to hence resolve this issue would be either install a Custom ClassLoader or use OSGi
I was looking for examples on how to create an XML File in ANT for Java project using Apache POI library. I encountered this statement:
POI 3.5 and later requires the JDK version 1.5 or later. Versions prior to 3.5 require JDK 1.4+ here
I am using Apache 3.9 and set the JDK of my project to Java 1.4 and I didn't encounter any error when trying to run my program via eclipse. But my question is if I make build.xml in ANT and deploy the JAR file. Will my project still run(3)?
Extra info
I created a build.xml using the ANT plugin in eclipse then Run as --> Ant Build. I didn't encounter any error.
Also set the JRE to JDK1.4
I haven't tested this yet if it runs or not because I still don't know how to add a JAR configuration in build.xml... I am still learning how to use ANT.
If the project states that JDK 1.5 or higher is required it means that usually no testing is done with lower versions. It might still work (to some degree) as you found out, but likely will stop working with newer version of Apache POI.
I have an existing Java project in Netbeans that uses Swing and I would like to start using Java FX 2.0 for some components in that project.
I have dowloaded the latest version of the JDK (1.7.0_03) and enabled JavaFX but when I try adding an import javafx.xxx statement, Netbeans can't resolve the link. Do I need to manually add some JARs to my list of external libraries?
Project Properties use "JDK 1.7-FX Enabled":
which is configured this way:
If you created your project in older NetBeans it can miss libraries from FX enabled plaftorm.
You can:
either recreate the project in NetBeans 7.1+ and copy sources
or include next library to the libs: C:/Program Files/Oracle/JavaFX 2.0 SDK/rt/lib/jfxrt.jar