Is it possible to run a Java program inside a Flex application? - java

I would like to be able to incorporate a simple game, written in Java as a component within a Flex Application. Am I crazy?
Flex can display HTML, and SWF, it can also call JavaScript - but can I incorporate an applet somehow?
I do NOT mean kludging it in as a sister component within a browser, but actually within the flex application itself, so that it could also run under Adobe Air, for instance.

No, Flash doesn't have a JVM. You would need to convert your Java to ActionScript somehow.

Running a Flex application inside a Java program is possible, not the opposite.
It might be possible to compile a Java Virtual Machine (if it's written in C) using Alchemy... but I don't think you want to go there, converting your code would be easier and cleaner ;)

Related

Can we use Dukescript as an applet replacement?

I read that DukeScript, a technology meant to bring Java to every client without the need of a plug-in.
Can this technology used as an applet replacement?
In geneneral I'd say yes.
Is there a particular reason why you would choose to use java applets in the past, meaning: did they need to do things like accessing the hardware and/or file system?
If your applet would do nothing more than what JavaScript would be able to do, then yes, you can definitely look at Java to to JavaScript solutions like GWT or DukeScript. They're quite different: one translates Java source code to JavaScript, the other one uses Java VMs written in JavaScript in order to run bytecode. Regardless, they're subject to the same limitations, when deployed to standard browsers. DukeScript though can be packaged up as a standalone app, running inside the JavaFX browser or as a native app on mobiles, therefore it can do more than standard JavaScript can do.

Java and Macros project

Basically, for a project i'm thinking of making a macro recording application, with a gui. It doesn't have to be brilliant, just basically functional. Are there macro api's for java? Ideally i'd like to use java, its where most of my limited experience lies. If not then what other languages could be recommended?
I'm using linux myself and was alerted to the xMacro terminal app. what id like is the basic record/play of this with a gui. Any ideas?
For capturing actions outside the java application, you will need to use JNI, since Java doesn't supply the appropriate tools to do that. So you should consider doing that in another language.

Java applet in a Delphi form

Is there any way, without using TWebBrowser, to load a java applet in a Delphi form and interact with it?
Theres a page which contains a applet that I want to show inside my Delphi app (in a particular form) and after the user close it (or do any other operation) I want to interact with it (getting some details about what user did).
I know that TWebBrowser is capable of loading a java applet, but it will not let me interact and get what I need.
Similar thing can be done with a .Net assembly, but I have not seen anything like it using a java applet.
Edit:
As #PA pointed out:
"it will not let me interact" ... well, that's the actual reason for browsers running java applets inside a sandbox
Well .. that was not what a meant. I meant I am not able to get a value from a edit (for example) as I am able to do with other languages. I know that java runs inside a VM, but .Net runs as well and i am able to interact with .Net using some COM and stuff like that.
I think the only way to use Java Applets in Delphi programs wihtout TWebBrowser is to use ActiveX technology. May be this link from google can help you: http://www.oracle.com/technetwork/java/index-jsp-141438.html
May be you should take a look at Java Native Interface (JNI) technology. For example, you can find its Delphi implementation here.

Is there a way to make a very simple IE browser with java?

I have a small project that i was wondering if it is possible to do with java.
I know that VB .net has the ability to make a simple web browser using an Internet explorer interface. I was wanting to do the same thing with java. Unless somebody knows how to compile VB on linux and would like to explain it to me.
Please tell me if you need anymore information.
JEditorPane has limited HTML rendering support, but no javascript engine
If you want Internet Explorer specifically, it's not going to be possible in the same way. VB.net uses the part of Internet Explorer that is built into the system. In other words, it is referencing a part of the Windows system, so you need to be running Windows to use it, regardless of the language.
You would need to use a tool such as http://www.ezjcom.com/ to get a COM wrapper in Java, from there you can embed IE as an ActiveX object.
All of these pieces might make it a little slow or cumbersome, but it should be possible.

How can a java library be ported to the web?

How do you take a java library that is for the desktop or an applet and make it so you can use its functions for a web page? I know not all things are meant for the web, but can you call a "regular" java class in an apache/tomcat setup server and it "work"? Do you have to so something to it to get it work with a web page?
I was interested in jgrapht for the web but it looks like all desktop or applet and I don't know that it would be possible to return its graphics to the browser, but maybe its libraries and a generated .png rendered by the browser.
Although there is debate on applets being alive or dead, I am not interested in using one at the moment, as it appears it is dead, albeit with new possible life in the latest update 6u10. I don't know that I want to invest in JavaFX either.
Johnny, the thing is that you have to decide what you mean to do. You could, for example, use JGraphT in server side code; the graph could be visualized in a bunch of different ways, like JGaph or graphviz. Then you would output the visualization in some form that works on the web and put it into your web page. In JGraph, that probably means a print interface that generates SVG or PNG.
Or you could emit the graph structure as JSON with a simple walk of the graph and interpret it on the fly in the browser using Javascript.
It's hard to answer the question generally, because it strongly depends on how you mean to use it.
Yes, it is possible to use a java class or jar file in a web appliaction, but it also depends on what you want to do with it.
For example if the library is for mathematics and you want to return results back to the users on a web based application, this is definitely possible. There are many other examples I can give but they are all the same.
As for displaying charts, I have successfully used JFreeChart in a web application using Apache Wicket (which rocks btw).
So to answer your question, you don't really need to "port" the library, you just need to use it and display it's output to a web page instead of a java desktop GUI.
Of course their might be some libraries that are specifically designed for Java GUI stuff like Swing or AWT. But for the most part there is no difference in using a Java library in a J2EE environment or a J2SE environment.
There isn't a closed-form answer to what you are suggesting: porting a Java Library to a browser's environment and using its functionality.
If you are interested in graphing things, here are a few things you can try:
Open Flash Chart - a scriptable flash app that will produce graphs
Bluff - a Javascript library that produces graphs
processing.js - a port of the excelling 'processing' library to Javascript
As for accessing Java-based functionality in the browser, there are some approaches for that. One is to use a toolset like GWT that complies java into an HTML/Javascript/Java application. Another is to use an AJAX-based technology like Direct Web Remoting. It really depends on what you are trying to accomplish.

Categories