Import appengine library in a gwt module - java

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.

Related

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.

How to refresh java changes in xpages

I am developing an application on xpages, with Domino version 9.0.1 FP8. This is the first application in which I have developed a call to java classes through a one-button SSJS event. But specifically I am consuming a web service using the technique presented in the article. What I noticed is that every time I change something that has a direct relationship with java, such as the java classes created and stored in the java folder of the designer or in the call of the web service method inside the SSJS event, an error is listed below . The only way to solve the problem, at least until now is to restart the Domino server. It's no use clearing the project, rebuilding it, and restarting http.
Does anyone know how to solve this problem? Is there any command on the Domino server that reflects this change? Is there any parameter in the application that I have to configure?
As we can see from the error below, it seems that it does not find the web service client classes that are located in a jar in the application jar folder.
HTTP JVM: java.lang.NullPointerException
HTTP JVM: at com.ibm.domino.xsp.module.nsf.ModuleClassLoader.getResource(ModuleClassLoader.java:206)
To solve your specific issue, issue res task http at the console. There are other workarounds posted in the comments to the main question that may be more practical for your situation though.
As a workaround you can rename the jar file when you make changes to it, import the renamed jar file and delete the old jar file. This way Domino will see the changes in the jar file.
I am using the rename trick whenever I make changes to code assembled in a jar file.

LibGDX gwd not inherit a required module

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

Dart: How to setup a project

Since my attempt to set up a Dart project myself I think I miss something fundamental since I didn't succeeded. So I still need the help of the community.
Coming from GWT I am used to a single application forming a single JS file which is ran and will augment a HTML element once it is recognized by the application.
There will be usually two JS files, one for the user-frontend and the web applications backend application.
I want a solution with an incremental build during development time (which I guess Dart offers when used in Dartium)
I have an inhouse web framework that I want to be started and used to send the Dart files for the Dartium session. How this will integrate and interfere with the debug sessions?
Update regarding web framework:
The web framework is a component based rendering engine, including database and uses its own resource management including everything http related like setting the cache flags etc. Its about 1.5 MB with 1200+ tests. Its simply everything you need starting with a simple servlet. Its also using an embedded jetty.
The relevance here is that I need to know how the debugger connects to Dartium and how it finds the files once an instance is running and delivered a html file containing dartium sources, so how can I start my own web server at a given port and still have dartium debug capabilities?
Update regarding the former answers:
I tried it but after two days gave up to learn more and do some other stuff. I just don't know why it is just not possible to add a simple file to the root package of my Dart module like the good old package.html (javadoc) fil. I then just add the Dart libaries to my project and the Dart plugin adds the required Dart nature to the project and creates a builder entry, done. Why do I have to do all the fuzz. Or even better why cant I just annotate my Module's main class to form a module and so I can replace the extra file completely?
I guess the Dart plugin has a model of the Dart code already so discovery is done on the fly in Eclipse.
I also do not know why I cant put my dart code in a dart source folder like src/dart/main and src/dart/test.
Or is this possible? I am still trying to get this done. I will use a fresh Eclipse 3.8 install and check if I can get Dartium to work. Just installing the plugin seams not to do the trick.
Update regarding the JS generation:
I cannot understand why Dart is not offering an incremental build of JS files. Even if it is a single file. It should not be that hard to debundle the given compile steps. I guess it will be something like compile each source file independently and link those together, do some tree shaking and done. Would be awesome if this can be made possible. Remember one can hold a model of the output file in memory (or on disk) and know what part of the js relates to what source file. Then just look up the link symbol tables and write back the part that has changed.
For me the killer feature for Dart would be the ease of configuration as I outlined and the incremental build of JS files making co-developing in JS a no-brainer. I guess in the end both JS files will be just about 750kb combined. So all the stuff with additional compression would not force me to upgrade my 8GB memory or will stress my SSD at all (350MB/sec for writes in burst mode).
Is there any work planed on this? Would be great to have Dart as the final solution for JS creation but to be honest I do not understand why GWT is the way to create JS this way. An incremental build and easy setup for GWT would be also welcome.
Seems not to be a question ...
In Dart you have usually one JS file because Dart on the server runs native (without transpiling)
With Dartium you don't have a build at all because it also runs Dart natively.
You build to JavaScript only for deployment (and of course to test the build output before deployment).
The debugging is done by Dartium itself (you can use the Chrome DevTools debugger without DartEditor if you want). DartEditor access the debugger API of Dartium and acts as a remote display/control.
Debugging web clients loaded from other webservers is supported.
What might cause some work is setting up your custom web server so that it forwards requests to source files to pub serve the web server used by DartEditor (or standalone).
pub serve runs transformers (on the fly code transformations/generation). Some framework depend on transformers being run on the code to make it functional.
I have no idea what this means but I don't use Eclipse/Dart plugin.
[Update regarding the former answers] I tried it but after two
days gave up to learn more and do some other stuff. I just dont
know why it is just not possible to add a simple file to the
root package of my module like the good old package.html file
for the java docs and then all i do is add the Dart libaries
to my project and the Dart plugin adds the nature to it and
creates a builder entry, done. Why do I have to do all the fuzz.
Or even better why cant I just annotate my Module's main class
to form a module and so I can replace the extra files?
To integrate Dart with your Java project create the Dart project independent from your project and move the Dart build output to a directory where you have your other static files.
While development configure your web server to forward to pub serve as explained above.
As already stated in my first answer, this
[Update regarding the JS generation] I can not understand why
dartium is not offering an incremental build of JS files. Even
if it is a single file. It should not be that hard to debundle
the given compile steps. I guess it will be something like
compile a single file and link those then the magical tree
shake and done
is irrelevant. You don't do anything with JavaScript while developing.
If you load the page with a non-Dartium browser pub serve will serve
built JavaScript instead of Dart. Incremental build is in the works
to improve responsiveness. But incremental build is not available
for file generation (would make sense anyway IMHO).

Dart in Existing Eclipse Java Project

When I add simple dart files anywhere in my existing Eclipse project, what do I have to do and what will be the limitiations and work arounds in order to make it work.
Update:
Some additional information might be helpful. What I use is a custom web server serving dart and js as simple files (dynamically on request). So I can not simply follow the dart way of things. The dart files would be rather sources only being used during development and converted to js files before the actual check in of the new version.
Therefore I would like to add the dart files in exactly the same mannor I add my other source. So i would love to have something like src/main/dart and src/test/dart or something.
I would also like being able to run dart in the stand alone vm (stand alone application) instead of the web / browser to simplify some development steps like the development of the model / business layer and add simplified testing. Also we want to evaluate if there is the possibility to start dart side processes on the server for additional simplification.
So the scenario is:
Put dart files anywhere (especially in the source tree)
The web framework is non-standard programmer friendly, we can simply add resources from anywhere under virtual directories (src/main/dart -> localhost/dart/)
The dart files will be converted to js prior to checkin
Dart should be able to pickup the right files on debug
Testing and debugging should be possible in standalone mode and in using Dartium
So how can I do this what should I be able to configure.
Update2:
Dart will be used as a JavaScript replacement here. So in the end this is a mid-size web project where the JS/Dart code provides the glue to make the pages functional. It also will drive the backend application which might be single paged but its not decided yet. Best would be to see the dart application as of two applications at once where the backedn application is distinct from the front end functionality that is dynamically added as needed.
For the compilation process to JS I would not mind to create a simple program copying files, compile and recopy files and done. Wouldnt take that long since it would be only needed once or twice a day.
You need to create a Dart pub package.
That is a directory containing the file pubspec.yaml.
You can put the Dart script and HTML files in the web and or lib subdirectory of the Dart package.
When you run pub build the deployable output is generated in the build/web subdirectory.
This deployable files can be served by your web server like any other static web content like HTML, CSS, JavaScript files.
update
I can't think of a way doing this
Dart isn't like JavaScript where you add some event handler script here and there.
I can't see how this would make sense anyway. More information about what you want Dart do for you is necessary to answer this - see my comment above.
You need the build step prior to serve generated JavaScript.
A Dart app is built entirely at once not file by file.
this is what pub build does. The output is written to my_dart_package/build/web
You can debug Dart as Dart (in Dartium, DartEditor or any other IDE that supports debugging Dart code) or after the build step using source maps in a browser like Chrome, FireFox, ...
You can debug non-web code standalone using the debugger of DartEditor, WebStorm, ...
You can create unit tests that invoke methods on Dart classes (model classes, PODO, ...) without a browser.
When you want to debug code that depends on the dart:html package you can only do it using a browser.
update2
You could create three packages
- server
- client
- shared
Dynamically loading functionality is already supported. The functionality has to be available at build time but can be loaded 'deferred' at first access or on request but this has nothing to do with the server part of Dart this is client-only functionality. Any web server can be used for that (for example Apache).
The server usually provided some data APIs (HTTP, REST, WebSocket, ...) for the client.

Categories