i want to call a method startApp() ,located in the java applet file from a java script file.
i tried the following method
<APPLET name="drops" code="BigDrops.class" width=700 height=650 ></APPLET>
document.drops.startApp();
but it shows "has no method startApp()" when i looked in the console of the browser
But the strange fact i noticed is that this problem is occured in all computers except mine..the files are loaded in the dropbox.
When i run the applet using the dropbox url from my computer, it works fine
tell me why it does not work and also give the solution
LiveConnect calls from JavaScript are limited under some security level from 7u21 and 7u25.
Related
I'm working in Netbeans, developing a Java Applet, as well as a few simple HTML pages that take the form of a Netbeans Web Application. I make a MySQL database connection within the code of my applet. This has been working fine for about a day now (I added the necessary .jar) and I have seen changes in the database as a result of testing, both when I attempt to run the applet straight from Netbeans, and when I run the web application from Netbeans and use the applet embedded in my HTML. However, I recently have been getting a ClassNotFoundException after calling the line:
Class.forName("com.mysql.jdbc.Driver");
in my applet code via the Web Application. Note that this line still executes successfully when I run the applet and not the web application. Only accessing the applet in Firefox is giving me these troubles. I tried restarting Netbeans and Firefox, and still no luck.
I apologize for the vagueness of the question, I was just hoping someone else might have experienced this and would know what to do. I'm pretty sure I haven't changed any code that is related to this Exception (given that the Applet still runs smoothly when not HTML-embedded), so that's all the relevant information I can think to give.
You need to let applet know about library with jdbc driver. Here is how to do it:
Adding a Third Party Library to Java Applet
I have a java applet with a main class at Eclipse IDE! I would like to call a function on a javascript. I have a variable for example x and i would like it to give it at the javascript and i want to receive another variable from the javascript for example y on my java applet.
Here is an example of how to invoke javascript from java Applet here and how to invoke java Applet from javascript here
Your question a little unclear about exact setup. So I give a couple answers:
If you have JavaScript function and want to execute function in Java, maybe this help: https://developer.mozilla.org/en-US/docs/Rhino
If you have JavaScript run in web browser and web browser also load applet, look here: http://docs.oracle.com/javase/tutorial/deployment/applet/invokingJavaScriptFromApplet.html
If you have Java Applet run in Eclipse IDE and JavaScript run in website in other location, you must make Applet provide HTTP(s) server and use XmlHttpRequest in JavaScript for call applet. For this you must use polling from JavaScript to Applet as Applet cannot call function on JavaScript this way, but JavaScript can connect to Applet.
If you have different setup from three mentioned here, please post and maybe we can find better answer.
I have an html page, where I dynamically create applet's HTML code and insert it into the page with with javascript.
After that I call some applet's methods.
Everything works fine in other OS's, and user to work in some Linux machines before.
But now under Linux I get a very strange and too general error message:
Error calling method on NPObject!
I really don't understand what is going on.
When creating applet code not dynamically (not wit JS, just insert it into HTML in the template), it works fine.
What could this be?
Any thoughts?
Thanks.
What could this be?
The latest in a long line of applet/JS/browser/CSS interaction bugs. Here are the hits for applet liveconnect.
Any thoughts?
Don't fight it, but instead use another strategy. I suggest:
Load the applet at page load.
Hide the applet using CSS (move it off the visible page, or make the size small).
Trigger JS that interacts with the CSS To reveal the applet.
So I have created an applet that creates a file on the local hard drive, and eventually uploads it to a CGI that I have created.
When run on IE, the applet works fine, and creates and uploads the file properly.
However, on firefox, I get an error on the Java Console, access denied, showing me that it simply can't create the file. I created the certificate myself, and did not buy one or have it verified through a company.
I need a solution that will work for anybody who potentially uses the applet, meaning the fix can't just be editing my own settings, unless I can do that with every computer that accepts the certificate.
Unsigned applets cannot access local disk on all browsers. It worked for you in IE because I believe that you ran it from file system (not via http). So, the right solution is not to create file on disk. Create content in memory and upload it. But remember: you can connect only to server the applet was downloaded from.
If you really have to create local file you have to sign the applet.
May be, some setting has to be done. One of the reason could be your Mozilla Firefox is not java enabled.
Check the following links :
A fix for Java applets not loading in Firefox
Applet loads but hidden in Firefox
To test whether java is enabled or not in a web browser, click [here]
This bug may be relevant.
It states that Firefox kills java applets that take too long to load. I have an example that works fine when loaded from a local resource but fails when it is remote. Sometimes, reopening the applet can make it work as it appears that it loads more and more of the classes each time.
I am working for a developing firm and am doing a major redesign on a Web Application, which reloaded everything after each click, to make extensive use of Javascript, so it actually feels like a real Web application. One of the Features is to use a web-based Painter (think of MSPaint on the Web), which I embed on the Page on Demand. After the image is painted and uploaded, the Web-app then unloads the applet and proceeds to show the directory where the file was uploaded to.
This is where Trouble starts. It all works on IE and Safari, but not on Firefox 3.5 (3.0 works perfectly though). Firebug tells me that the expando property is missing.
The Web-app Tiparlo which I was working on before had a similar Problem (in fact, any manipulation done on an applet via jQuery is faulty) but solved that Problem by wrapping a div around and controlling (hide and show) the div instead of the applet. This, unfortunately isn't applicable on this Web-app, because the Applet has to be destroyed and not just hidden and shown, as it takes up too much resources to be run the entire time where it is not needed.
To make it short: Is it possible to make an Applet destroy itself via Javascript? Alternatively: Is there a workaround on the jQuery/expando/applet problem? I know that applet is deprecated in HTML 4.01 strict but changing it to object is not an option right now.
EDIT: I have added a Picture of Firefox + Firebug to show you the actual Error Message. Posting Code does no god, since it works flawless on every other Browser and is a Firefox 3.5 specific Problem. Here be pictures
Note: You can ignore the JS Bug coming from button.js.
You could always load the applet in a an iframe and just navigate away from the page where the applet is loaded. This will kill it.
Your other option if you want to call the destroy from javascript would be to put something like this in.
<script>
document.MyApplet.killApplet();
</script>
public void killApplet() {
AccessController.doPrivileged(new PrivilegedAction() {
public Void run() {
// kill the JVM System.exit(0); return null;
}
});
}
This is not a nice way to kill an applet but on newer browsers it does not throw a JS error, on older ones like IE6 it will throw a js error.
I would suggest that you create a class that monitors the applet to be killed. run the monitor as some sort of servlet and get javascript to post 'kill applet' commands when it needs to be killed.