LibGDX gwd not inherit a required module - java

I have a error with exporting HTML using GWT.
Errors in 'file:/D:/Dropbox/Programming/Multi-platform/3D%20defence/Dendron3Dv2/core/src/psyrot/td/dendron3d/shop/ShopScreen.java'
Line 222: No source code is available for type java.sql.ResultSet; did you forget to inherit a required module?
Line 244: No source code is available for type java.sql.SQLException; did you forget to inherit a required module?
How to add sql or my mysql-connector-java-5.1.7-bin.jar to inherit in .gwt.xml?

GWT transpiles your Java code into JavaScript. The MySQL driver there most likely uses a native interface and therefor can not be transpiled. If you still want to try, you would have to provide the source files too for the GWT compiler.
Even if you could transform all of this into Javascript, you would most likely don't want your Browser clients to connect directly to your database or have them install MySQL on their local machines in the first place.
In web scenario like this, you are best off using some REST-API (since you are on java already, springboot make this rather easy) and access your data from the browser via this API. Also see https://github.com/libgdx/libgdx/wiki/Networking

Related

How to retrieve real-time data from an existing Java application without access to source code?

Update: Jun 10, 2022
I have successfully been able to create a demo application with AspectJ integration that could extract variables from the demo application. It was quite a hassle since there's a bit of trouble going on with Eclipse AJDT integration.
I was able to use CLI Java and ajc (AspectJ compiler) to achieve binary weaving into my demo application.
Original Question:
I am trying to retrieve real-time data from a running Java application and push it into an API I have on a server.|
I have no access to the source code of the running application; I only have the Jar file. I have tried decompilation into .java files; however, due to the scale of the app, I was not able to fix all of the missing access$000 function calls.
Is there a certain approach I should use when retrieving real-time data from an existing Java application? Has that been done before? Am I missing something that I am not aware of?
Any help is appreciated.
This is big challenge obviously. If you can glean enough understanding of how the program works from decompiling and reading log files to target some methods where you suspect there's data of interest to your API, then I would read up about Aspect Oriented Programming [AOP] and use those tools.
With AOP you can modify the classes in the jar file at runtime as its loaded by the JVM and access the classes.
For example: You can gather data from:
fields within the class that owns a method
parameters passed to a method
value returned from a method
Once you gather the data, you can also insert calls to your API.
Here's a place to start - https://www.baeldung.com/aspectj .

How to know if I'm using external or internal libraries in Java?

So, I have to write this code and it must use only internal Java libraries.
I have to read the HTML content of a URL page and I have managed to do so, but I'm not sure if I have only used internal libraries because I'm not so familiar with Java, can some explain to me please?
I read that if it starts with "Java" it means that is a internal library, but Im not sure.
Below there is a image of what I have used. Thank you.
First pic: used in the main class
Second pic: used in the reader class
If you are not pulling any external dependancies, as external jar's, maven or gradle dependancies, just using what ever JDK provides, then you are using internal Java libraries.
In both of your images imports are from JDK (internal Java libraries).
For other import if it starts with java or javax most likely it is internal library as well.

Import Neo4J API in Netbeans

For a project I am building a Java GUI from which queries can be sent to Neo4j, to make it easier to do particular analyses. To get this all working, I have downloaded a .jar folder containing all relevant classes (neo4j-javadocs-2.1.7-javadoc.jar). I have loaded the library through the project->properties->libraries->Add JAR, but I can't seem to import the classes I want to use in my GUI (neither automatically nor manually).
I am dabbling in Java, so it is probably a basic oversight that I am making, but with the help from tutorials online and trying different commands (like entering the path of the .jar file) I can't get it working. One of these tutorials is specific on the Neo4j library, so I am very confused. That tutorial is written for Eclipse, instead of NetBeans which I am working with, but as far as my knowledge goes that shouldn't matter for the commands
I don't have enough reputation to post direct images, but this link contains a screenshot. If more information is required, let me know. http://i.stack.imgur.com/lUytK.png
Additionally, when I normally add a class that is not imported, there is an automatic function to import the class. This option is missing for my specific class, so maybe I added the library in an incorrect way?
http://i.stack.imgur.com/QeDX4.png
Edit: Issue resolved thanks to a colleague that came in. Apparently I loaded the Javadoc where I should have loaded to individual classes from the lib directory.
It really should work.
Try to save all changes. NetBeans reparses the classes when you save them.
Try to build your project manually from command line using Ant build script
Use Maven, Ivy or Gradle for Dependency Management then you can depend on the Neo4j artifacts.
For sending queries to the server you actually don't need Neo4j artifacts.
You can also use the JDBC driver, see http://neo4j.com/developer/java

Import appengine library in a gwt module

I have a web application that contains a GWT module. In the client of my GWT module I want to use the library "com.google.appengine.api.datastore.DatastoreService" but, when I compile the gwt module, I have this error: "The import com.google.appengine.api.datastore cannot be resolved". Where is the problem
The first and most obvious things to ask are:
Have you downloaded the java appengine SDK and have you made the JAR files contained within available to your app?
Are you using Eclipse?
I don't think it is possible. Anything on the client side gets translated to javascript that is ran in the browsers. You can directly access a database through javascript in the browser. Not all Java code can run in a browser. In fact not even all the JRE classes can be used either. If you need a type of storage on the client side, look at html 5 local storage.

Google App Engine "repackaged" package

What is the purpose of the classes in this package?
I want to use Base64 encoding in my app. As I'm typing away in Eclipse, I am prompted if I want to import a class called "com.google.appengine.repackaged.com.google.common.util.Base64"
I can't find any documentation about what this class does. No javadoc, or no mention in the Google App Engine manual (that I can see). Is this some kind of "hidden" API that I'm not supposed to have access to?
Is this some kind of "hidden" API that I'm not supposed to have access to?
Yes.
The purpose of repackaging Java classes is to have a private copy of a library that otherwise might conflict with another version of that some library (that the application developer adds to his project as a jar file).
It is one possible answer to JAR-hell.
Even the JDK makes use of this mechanism, e.g. with com.sun.org.apache.xerces which is an XML parsing library developed by the Apache Project that Sun choose to include (repackaged).
Do not call these classes directly. (You could, and they would probably work okay, but as they are not part of the official API, they could disappear in the next version).

Categories