jasckson libraries in google app engine not included in whitelist - java

when I have these imports in my code or use any of the classes and and methods, I get this error from intelli J IDE.
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
Class 'com.fasterxml.jackson.databind.ObjectMapper' is not included in App Engine JRE White List
this does not result in any Maven build errors but or any errors in production. but why is the IDE flagging the error.
Class 'com.fasterxml.jackson.core.type.TypeReference' is not included in App Engine JRE White List

Those imports aren't part of the Java Application Programming Interface (Java API)
They are library that are created and in order for you to use them, you have to download and add the jar file in your java build path library

Related

Where do I find the source code for packages that I import in Java?

When I import a package, say e.g. import java.awt.Graphics, where can I find the source code for the Graphics class in my JDK installation on my Mac? I know the path to my installation is /Library/Java/JavaVirtualMachines, however I don't really understand exactly where the class is being generated from in the installation.
Thanks!
Assuming you are using a modern IDE, such as IntelliJ, along with a build tool such as Maven or Gradle, you should actually be able to just CTRL + CLICK on any method in the java.awt.Graphics package to view the decompiled source code. Developing using an IDE with something like Maven is recommended in most cases, so if you are not already doing so, now might be a good time to upgrade.

The import com.badlogic cannot be resolved in Java Project Libgdx Setup

I've just tried to setup Libgdx to start making games, i followed this tutorial https://www.youtube.com/watch?v=S9fs1PVTyUc&feature=youtu.be
in conjunction with the libgdx grdale setup. However an error shows up in the Java project which says:
The import com.badlogic cannot be resolved
I am using Eclipse for Java IDE. I believe I have the Android SDK installed. I think it may be to do with the setup but i think the latest updates are there and i tried deleting '.m2'ccahe, which is not there any more btw after i deleted it (not been replaced), but this didnt work. Any ideas?
heres my code for the java proect:
import com.badlogic.gmx.Game;
public class GameMain extends Game{
}//'com.badlogic 'gets an error and so does 'Game'
The issue you are encountering is your eclipse project "CreateGame" is not setup correctly. It is missing the files needed to use libgdx.
Possible Solutions:
Use the libgdx project setup tool and then follow the instructions here to import the project to eclipse. (easy)
Add the missing library files to the project (hard)
Also make sure your game code is going into the game-core project as this project is used by each platform you are targeting.

Creating a Java jar library to use on Android project

I am working on developing a game for Android and I have a lot of the code written on a java application. I would like to use the classes and methods in the Java application within my Android application. I am using Eclipse to develop my application so I tried to create a Jar for the Java application By doing: Right click project->Export->Jar I then saved the jar somewhere and added the jar to my Android buildpath. When I try to use methods from that jar I get compilation errors because Eclipse cant find the methods. Am I supposed to have any import statements? The name of the package on my java app is (default package) so I am not sure what the import statement would be. I would appreciate any help.
EDIT: I changed the package name of my application so that I could import the classes within it and that got rid of the compilation errors. When I try to run the project I now get NoClassDefFoundError Could it be that I am exporting the jar for my Java application wrong?
Open Project properties -> Java Build Path -> Order and Report tab.
Try to check jar check boxes,
see example:
To make sure that you created jar properly, here other snapshot of jar export:
Rename the package first. http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
Yes, you need to import the package inorder to use in a class. Else the compiler will not identify the codes. Import the jar into build path and import the package into the Java code as :
import java.util.HashMap;
If I understand your correctly you exporting a Java .jar (built using Java compiler)? As far as I know Android does not understand Java bytecode though the compiler for Android understands Java source code.
I'd suggest you just put all that source files in the Android project and compile them there, hopefully you aren't using functions that Android API does not have.

Google App Engine Java - javax.servlet source files

Using Eclipse (juno) and GAE plugin, I've compiled and ran the "guestbook" example (https://developers.google.com/appengine/docs/java/gettingstarted/creating) without any problem.
Both of the class of the example extend "HttpServlet" class of javax.servlet.http package.
I'd like to see the source code (and javadoc) of this class and of the other class of the package (and super package), but I can't figure out where they are.
They are not in
Program Files\eclipse-jee-juno-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.0\appengine-java-sdk-1.7.0\src
(I've tried all of the files in there)
Binary files should be in servlet-api.jar in
Program Files\eclipse-jee-juno-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.0\appengine-java-sdk-1.7.0\lib\shared
I've googled a lot without success.
Anybody knows where to find sources of javax.servlet package?
Thanks a lot.
The sources for javax classes are included with Java EE distributions and not the App Engine SDK. If you can't find a local Java EE distribution, you can try downloading the sources here, and referencing them from within Eclipse.
Project properties -> configure build path -> libraries -> drop down arrow of App Engine SDK-> drop down arrow of servlet-api.jar -> click javadoc location -> click edit -> enter javadoc URL : http://docs.oracle.com/javaee/6/api/

Use Android objects outside Android

In a Java project I am using a class that is in an Android project and uses an android View object. When I try and use that class in the non-android project I get a no class found error at runtime. How can I import android.widget.view.View into a non-android project? Can I add it to my project build?
Without the android platform runtime, ie.. DalvikVM, etc... you will not be able to run any of the framework necessary to render "Views" in your Java project. Did you think of that?. But to get it coded you would at least need to import Android.jar into your Java project build path. It will likely find the Widget package, but the Widget package will be looking for the Android SDK, etc...
What does android.widget.View give you outside of the Android environment??

Categories