I'm developing an application in Java using Pivot for the GUI elements, in the Eclipse IDE.
Since the end product is supposed to be an applet, I am wondering, if there is a way to launch the application in a browser through Eclipse during the development phase.
I don't want instructions on how to write an html page that loads the libraries and jnlp or something like that, I'm only asking if there is a way to automatically do all that in one-click-mode through Eclipse.
The Run Configurations in Eclipse support launching a Java Applet.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-launching_java_applet.htm
The Hello World tutorial page on Apache's website gives you the information needed to configure the applet.
http://pivot.apache.org/tutorials/hello-world.html
[Edit in response to comment]
Open the Run Configurations Window and add a new "Java Applet". That's what the first link was meant to indicate you are able to do.
The second link provides a snippet of how you're supposed to run applets using the BrowserApplicationContext, and it's quite specific in the values you provide (and map one for one to the Eclipse launcher values):
<applet code="org.apache.pivot.wtk.BrowserApplicationContext$HostApplet"
archive="lib/pivot-core-[version].jar,lib/pivot-wtk-[version].jar,lib/pivot-wtk-terra-[version].jar,lib/pivot-tutorials-[version].jar"
width="160"
height="80"
>
<param name="application_class_name" value="org.apache.pivot.tutorials.HelloJava"> </applet>
The Main and Parameters tabs should be the only one you're looking at.
Related
I have GWT-Maven project created using IntelliJ. I can build and run it but the browser shows a strange error on home page. How to fix it?
I've tried to create new project and import the existing code but it doesn't help.
Project download: GwtStudy
You need to run it GWT Development mode with Jetty.
The you will get a code server at http://127.0.0.1:9876/
and a web server at: http://127.0.0.1:8888/yourapp.html
See also this video: https://www.youtube.com/watch?v=kx9RxrQZnFA
The tutorial is slightly misleading. You need to run the app by choosing "GWT Development mode with Jetty" and not "GWT development mode" as one may believe following the tutorial (the super dev mode is the standard nowadays).
If you run the app using "GWT development mode" you will start only the code server, that will run the java code, but it will not be able to serve the html page that hosts the stockwatcher application.
If you run it with "GWT Development mode with Jetty" you will get a code server at http://127.0.0.1:9876/ AND the web server at: http://127.0.0.1:8888/stockwatcher.html, that is the URL that you need to open with your browser to see the page that hosts the app (you can see that the docs shows the browser opening the url at port 8888 and not at port 9876).
The answer of Jankos is right but for me it was not enough clear. The video is not strictly needed or related to solve the issue, so I added this answer to help gwt beginners like me.
This is the CodeServer, which compiles your app on-demand, and serves the compiled scripts and their source maps.
You need another web server to serve your webapp, including most importantly an html page that includes the nocache.js script.
Depending on how you "run" your app this may or may not already be the case (you'd need to give more information).
I have a html file, there are links in it, I wonder if there is a way to use those links to call a java program to generate another html file ?
Something like this :
<Html>
<body>
Some text
<A Href=[somehow point to a java .class file to run]>My Link</A>
More text
</Body>
</Html>
I know how to use Java to generate html, what I'm asking here is how to pass a parameter to this local java class so that it can generate html file with the input ?
So if the Java program is called : MyHtmlGen.java
Then the class will be MyHtmlGen.class
And then if I run it from the command line, it would be like this :
> java MyHtmlGen my_input
But I don't know how to turn that into the html link above ?
You could use WebStart to launch an Java application from a browser interaction.
The section of the linked documentation titled: "Running a Java Web Start Application From a Browser" provides a demo you can try. The link to the Java application is provided as:
Launch Notepad Application
That documentation states that when you click the link:
Java Web Start software loads and runs the application based on instructions in the JNLP file.
That isn't the behavior I get on Safari 7.1 on OS X 10.9 with Oracle Java 8u40 installed. Instead, I just get the jnlp file downloaded and can double click on the downloaded file to run the application. I think on some browsers, Oracle may provide a plugin to the browser which is able to launch the jnlp referenced application automatically without the user having to also double click on a downloaded jnlp file. Perhaps if the Java deployment toolkit were used, rather than a straight a href link, the user experience might be a bit more seamless.
Note: browser manufacturers have been phasing out support for plugin technology like this, so the experience or even the ability to automatically run the referenced application may vary for both you and your users. Additionally, allowing such plugins to run within a browser environment can increase the security attack vulnerability surface for a user's browser. WebStart is also quick a tricky technology to use and support for your users. So for these reasons I normally don't recommend using WebStart as a deployment solution.
That's just impossible. A link <a> will fire a GET request to the server for the URI set in the href attribute, it's not meant to execute a specific piece of code. If you want to execute code when clicking a link, use JavaScript, but be aware that JavaScript cannot start an instance of JVM and run your exact Java application.
On the other hand, maybe you should look into Applet or JavaFX and embed the java application in your page. Or probably you may submit an action to the server, and at server side you may start the JVM and execute your Java code.
Originally I had an applet that contained SQL server/jdbc stuff and wanted to use that applet in html but I guess it's not good to use SQL in html? because i kept getting millions of errors/exceptions and realized my applet would only work if i commented out my SQL code.
but anyways, is there a way that I can have a button on an html page that when it is clicked it will run the runnable JAR application not the applet? without causing errors..
I'm not sure what a JAva Web Start is or what a JNLP is but if anyone could explain/help? the Oracle Website doesnt explain well enough like how do i create a JNLP?
I currently have a runnable JAR file that was exported from eclipse that opens & runs when I click the icon
You are correct that Java Web Start is what you want to use. You have your JAR file built already, so you should be good to go by following this Deploying a Java Web Start Application tutorial
This will walk you through signing the JAR file, creating JNLP file. This web site contains an example of a JNLP file, and also contains more documentation on the structure of the JNLP file here
You'll then create a few simple lines of JavaScript, to be triggered when the user clicks a button. Something like this, as mentioned in the tutorial:
deployJava.createWebStartLaunchButton(URL_TO_JNLP, '1.7.0');
In web applications that run with Tomcat from Eclipse, for example, we can right-click on an element in the page and inspect it (with Firebug, for example), and we can see the element's ID, class, etc. If we have a JAVA Swing application that we run from Eclipse (right-click project ==> debug as ==> eclipse application), can we do the same thing so that we can see which method, for example handles that element, or whatever? Can we inspect a JAVA Swing element as it runs (from Eclipse)? I already checked swing-inspector, but I do not want it.
Thank you
I am sorry that I can not offer you a solution for Eclipse. If you can use Netbeans it includes a Visual Debugger feature. It is simple to use and it is integrated in Netbeans by default.
I have a problem when I use the applet tag within Internet Explorer 6.
Here is the code I use:
<APPLET
height=1024
archive=consignation-applet-signed.jar,httpclient-4.0.1.jar,httpcore-4.0.1.jar,commons-logging-1.1.1.jar,log4j-1.2.14.jar
width=1280
code=PilotageImpression.class>
<PARAM NAME="_cx" VALUE="33867">
<PARAM NAME="_cy" VALUE="27093">
</APPLET>
The problem is that it tries to reach two URL's on Microsoft's website. It's a problem when you are in a closed environment.
I read an article here: http://support.microsoft.com/kb/323207/en-us but it says that the problem is only known when using the OBJECT tag (I use Applet tag)
Does anyone know why does this occur with the applet tag?
If your user has the Next Generation Plug-In (Sun's 1.6.0_10+), it would be easy to deploy this applet along with it's natives, using Java Web Start.
JWS could also launch the applet with natives on versions prior to the next generation plug-in, but they would be free-floating, outside the browser.