I want to display a HTML file in my java GUI.
Big problem: this java program has to run on Raspbian (Raspberry Pi).
I used the browser from eclipse swt which worked perfectly on my PC, but there is no swt build for the ARM processor on my RPI...
A JEditorPane is too weak, because I need to display some pages with CSS
Is there any other possibility?
The easiest solution is of course to see of JavaFX is supported on Raspbian. If it is, then you can use the WebView component (http://docs.oracle.com/javafx/2/webview/jfxpub-webview.htm) and most of your problems will be solved. As pointed out in the comments below by jewelsea, this is not a feasible solution yet. This might change with future builds of JavaFX for Raspbian though, so keep an eye on it.
If, for some reason, JavaFX won't work (due to display drivers etc.) then you might want to reconsider your application approach. If you just need to display the HTML file, then you can write it out to disk and display it in the default system browser. If you need to interact with it, it becomes a bit more complicated - you'd basically write a small web server and then respond to user interaction that way. The user will be using their browser of choice, and you'll send responses back to it.
Related
I'm currently planning on making a simple IRC style chat client and server system using Java for practice. I did some research into different ways of including the client functionality on a webpage like applets and java-web-start. I would like to have the client running on the users machine instead of the server itself. As I interpreted, out of the two, the applet pretty much does exactly that and seems way less effort to set up.
However, it turns out that applets have their own graphical implementation using "Graphics" class to render things like text, lines and shapes. Instead of going for something fancy, I would like to use a simple console interface like cmd on windows or shell on unix systems.
Is it possible to have this type of console running on a webpage as java applet or would I basically have to code the entire graphical look using the tools provided by the Graphics class? For this practice project, it would be ideal just using simple functionality provided in console windows like "nexInt()" and "system.out.print()" instead of having to add complex elements for input and output.
TL;DR:
Is it possible to embed an OS console within a webpage using java and what would be the preferred method of going about it?
Is it possible to embed an OS console within a webpage using java ..
AFAIU it is not possible to embed a console in a Swing or AWT desktop app. As far as embedding that into a web page, that would require an applet. Chrome and FF have completely removed support for applets and IE is set to follow.
I want some way of creating a dedicated browser window for a browser (chrom-e/ium or firefox). Its content needs to be controlled by a java application (a http call to localhost or better a more direct way of communicating). These two should be bundled together in some way.
A little Background
I want to write a java desktop app but don't want to use Swing or javaFX for the UI. The UI should be written like a one page app and may be ported (at least partially) to the web. I have taken a look at the javafx WebView but would rather have a full fledged browser on my hands. It would also be nice to have a little more control over said browser to send files and read files in a more desktopish way. The only real requirement is that there has to be some java backend behind it and that is has to work offline.
Is something like this possible at all or is it just a pipe dream?
I am very almost a year late for the party, but:
There are a few (that I know) technologies that can help you:
Electron. It is basically what you want, you can use web
technologies to "forge" a desktop app, it's quite well known, I never used it but for what I have read that you can stick almost anything to it's "backend".
JavaFxWebView. There are some really nice ways to use it, you can
even use bootstrap and AngularJs, here is a example (not by me)
Yes it's possible and not all that unusual. Your app can open a default browser as described here -
https://stackoverflow.com/a/10967469/5087125
And then proceed to respond to http requests to your app.
My supervisor has tasked me with programmatically reducing a website's content by looking at the HTML tags to reveal only the core content. Importantly, this particular piece of the project must be written in Java.
Now having learnt about the differences betweenPlugins, Extensions, Applets, and Widgets, I think I want to use an Extension that calls a client-side Applet. My approach was going to be this:
Using the Google-Chrome API, I was going to display a button that
the user can click.
If clicked, the action is to launch a new browser tab that has the
Applet embedded within it.
The applet automatically sources the called tab's HTML code and
filters it.
Once filtered, the reduced copy of the original site appears.
So I have a few questions. To start, is it even possible to use an Extension with an Applet? Moreover, is it possible for an applet to look # another tabs HTML code? If not, is it possible to just reload the original tab with the Applet now embedded within it and complete the function. Thanks.
Javascript is already on most mobile web platforms. Java is not, and there is no reasonable way mobile customers will be able to install Java. Android, which runs many, but not all, mobile devices has a Java run time environment, and is basically a loader for Java apps. But an Apple iPhone is not an Android device... nor is a Windows Phone.
If you want to summarize content on the client, and in Javascript, as I see it you have two choices:
Succeed with some inner burst of genius where dozens of the best expert PhDs in Natural Language Computing have just begun exploring how to extract "true meaning" from text; OR
look at document.title and be done with it.
The 2nd approach assumes that the authors of web pages set titles and set a title appropriate for summarizing their website. This isn't a perfect assumption, but it is OK
most of the time. It is also a lot less expensive than #1
With the 1st approach you can get a head start with a "natural language toolkit" that can do things like scan text for unusual words and phrases. To get a rough idea of the kinds of software that have been built in this area, review wikipedia: Outline of natural language processing:: toolkits. A popular tookit for python is called NLTK. Whether you use a toolkit from java, or python, it means working on the server because the client will not have the storage, network speed, or CPU. For python there are server side app frameworks like django or web2py that can make building out a server app faster, and on Java there are servlets frameworks. Ultimately you'll need a lot of help, training, or luck and as I have hinted above it can easily be beyond the capabilities of a small team of fresh hires, and certainly way beyond what a single new developer eager to prove his/her capabilities can do in a few weeks on their own with limited help.
Most web pages have titles set like this near the beginning of the downloaded HTML:
<head><title>My Furry Kittens!</title></head>
You don't need to write a parser. If you are running in the browser, the title has been parsed into the DOM or Document Object Model already. The string "My Furry Kittens!" in this example would be available in the global variable document.title.
If you like, you could put a button into a plugin and let people push it to summarize the website. Or, they could just look up at the title. It is already on the page. Of course, if the goal is to scrape titles one can avoid writing a parser and use a "fake" headless scriptable browser like phantomJS or similar.
You can read more about document.title on the Mozilla Developer Network. MDN is a great reference for learning how web browsers work. They are the maintainers of the Mozilla Firefox browser. Most of what you can learn there will also work on Chrome, Internet Explorer, and various mobile platforms.
Good Luck!
How about implementing a local proxy server on the mobile device. The browser would just need to be configured to use the proxy, while the custom proxy implementation can transform the requested html however it likes.
I've been trying to understand how flash animations or a Java Applet work within a browser.
I can think of a couple of ways -
The Flash Player/Java Applet are machine code that's dynamically linked it, and given
some parameters about the area of the screen that belongs to them; after that, they
run within the same process space.
The browser exposes an API that the player/applet use to talk to it and they live
in a separate process. (Presumably they talk via sockets?) The API could correspond to
openGL/X11/some custom calls.
These possibilities still don't explain things like how a button click can make the
player full-screen, how it can play music, how it can inspect the DOM, etc. For that matter,
is the video displayed by decoding to a sequence of images, and rendering them
one at a time, or is there a more efficient way, e.g., of pushing the deltas in the image?
The Wikipedia page on Java Applets (1)
talks about how the applet is run in a sandbox (presumably a separate process), but
it doesn't say how the browser and the applet communicate.
Perhaps the answer depends on the underlying platform?
Any pointers to systematic discussion of this topic would be appreciated (as would
a reference to the APIs).
(My interest in this stems from an insatiable curiosity.)
I'm pretty sure plugins like Java applets and Flash run via NPAPI in most browsers. I looked into this matter myself some time ago and NPAPI was the answer I found.
In the case of browser and Java applets, the applets are typically run within the Java plugin, which runs as a separate process (you can see it e.g. in the task administrator in Windows).
The plugin creates an object for each applet in the DOM, and you can thus interact with the applet from Javascript. Anyway, calls to the applet that take a while to return do have the effect to freeze the browser, therefore I'd say the communication with the plugin runs in the same thread as the main refresh loop. This seems at least to be the case with Firefox.
We have 2 java applications running on MAC. One background application sends either a text or image to a clipboard, then the other application grabs that data and paste it in its application.
We have this problem when the app copies something on the clipboard, the background app won't be able to update the clipboard until it's UI becomes active.
Is there work around with this clipboard issue? This works on Windows and Linux, it seems to be a problem only on MAC.
Don't.
What you are doing is generally referred to as "interprocess communication". There are various strategies to accomplish this. One of the more 'correct' approaches, in your cotext of two Java applications, would be to use Java RMI.
Doing it in a non-standard, "hackish" manner like you are with the clipboard is more problematic...as you have discovered the hard way.
Even if you did manage to get it running, the possibilities of problems in the future are high. E.g.: Imagine a Windows update changing the behavior of the clipboard--it would break your app on Windows.