There is an applet on a HTML page. That applet loads a dll library and communicates with an external application through it. I can successfully load and work with that library. That library has functions INIT() and DEINIT().
The issue is when I try to call those functions again, the external app/library says that there is only one process can access to that app. It is an internal check. So I need a way to stop the Java process in order to start the app once again. But if I start the applet once, the Java process doesn't finished until I close the browser tab (or even the whole browser).
Is there a way to stop the Java process in the scope of the browser tab? And I need Java to start as soon as applet in the HTML page will appear.
You can't stop the JVM from the applet, it's managed by the browser.
You might consider switching to a Java Web Start application instead, it's started in its own VM.
Related
In my web application I need to launch a Windows application installed on client machine when a button in the page is clicked.
I know there are security policies in browsers that avoid this by default, but I also know application that do this. An example could be online meeting, web conferencing applications like WebEx or GoToMeeting.
How they do that?
I'm working with Java, so I'm wondering if Java Applets are an option to achieve this.
Is there some other well known way to solve this issue?
NOTE application execution MUST be allowed by user
The best way to deploy a Java desktop application is using Java Web Start.
And forget applets. Soon Chrome won't be able to load them (along with a number of other plug-ins) at all.
you can achieve it with applet. but user must allow to run it. it is hard to run some extern application from button or link because this is potentially danger behaviour. Remember the applet can not get access to the files on user computer and other servers (unless it is digitally signed)
I know this may sound like a silly question, but I was wondering if there was a way to run Java Applets on my server and embed them to a page in a way that the user would not have to "allow access" to the applet, because it wouldn't have direct connection with their computer. In other words, make an embedded java applet which wouldn't download to the client side? I understand that the lifetime of an applet is only in the web browser when a user activates a plugin and all of that.. So how can I run Java APplets on my server?
Theoretically everything is possible. Applet is a special java application that extends Applet or JApplet. Applet just extends Panel. You can simulate applet container by implementing your own dummy appet context and run applet on server side.
Now, you can capture its UI and stream it to browser using AJAX or even web sockets. You can catch mouse and keyboard events in browser, send them using ajax to server where your applet is running and emulate the same events on your applets.
But may I ask you "why?" I think these efforts can be reasonable only if you have a huge applet and do not want to re-implement it using other technologies. But IMHO it is easier to re-write your applet using ExtJs or GWT. In GWT it is probably the better way because GWT is a java that is compiled to javascript, so you will probably be able to reuse most of your code.
I have a web page where sometimes I need to communicate with a device.
This device is accessed with sockets, so I have a jar file with the support libraries.
When you want to get data from the device, you press a button, and a javascript method fetches the data using the library (no java code here)
The presence of the jar makes the java machine to start as soon as you load the page.
Since there is a lot of users that don't use this option (usually they don't even have the device, to begin with), they see that as a nuisance.
Is there a posibility to delay the java loading until the button is pressed ?
I don't want to redirect them to another page, that should be done in the same page.
You can load the jar file into a seperate div created dynamically via javascript, at the time you need it.
If you want to consider loading your application with java-webstart-technology, you can implement a button similiar to what oracle has on their page here
Basically what the button does is download the required jars specified in a jnlp-file and launch it.
I have an applet packaged with a third part dll (from JTwain). My applet scans documents from the TWAIN compatible default printer. The applet fails on a paper jam and won't recover. The user navigates away from the page and the applet is destroyed. When returning to the page it fails again. Closing the browser (which kills java.exe process on the pc), and then returning to the page clears the problem and everything works.
I want to restart everything without requiring users to close down the browser. I've added a GUID query string to the URL's from which the applets resources are loaded - so I know nothing is being cached. I've checked in the windows task manager and there is no process created by the dll, it's all happening within the main java.exe process. I tried wrapping the scanning process in a thread so I could interrupt it in the stop or destroy methods (just in case the applets thread weren't stopped when the applet was destroyed), but that didn't work.
Any suggest would be greatly appreciated. Ideally I'd like some way to restart java when the applet unloads (but I doubt that's possible).
UPDATE
I've spent a couple of days trying to identify what causes the applet to fail. I still don't know :(
When the paper jam occurs something (not my code), is producing a couple of popups. The first alerts the user of the jam, and can be closed by clicking the OK button. The second says 'reading from device' and hangs. It cannot be close with the red, close window, icon in the top corner - I kill it from the task manager and windows asks to send a report regarding the 'non-responsive program'. I assume these popups are produced by the dll. And given that the second hangs, my assumption is that a thread started by the dll has hung while retaining a lock on some component of the TWAIN application. I get
com.asprise.util.jtwain.JTwainException: Failed to open the specified data source:
Source: TW-Brother MFC-9970CDW LAN Thrown
..when I try to access the scanner.
I'm at a bit of a loss as to how I can get more information. I'm testing my applet on a windows virtual pc (so as to use ie7), and don't have a method for step debugging in this environment. (And it's crashing on third party code for which I have no source anyway)
I see only two practical options here:
Use an API that handles paper jam without problems. Of course, that is easy to say (get robust API), harder to find.
Launch the app. free floating using Java Web Start. If it freezes up, the user can kill it and click the link for another instance in a new JVM. Or the applet might also call BasicService.showDocument(URLof.jnlp) if it can detect a problem with the DLL and is not itself frozen.
Of course, you should also report the bug to the ..Asprise(?) developers. The optimal solution would be to have the problem fixed at its source. Anything we do here is a 'workaround'.
How can I execute a desktop application from a browser?. I have a web page with a button, when user click this button a simple java desktop application must run. How can I do this using jsp or javascript?
Java Web Start might be your solution.
To start a Java Web Start application, you simply direct the browser to the location of the JNLP file. Basically, the browser detects that instead of simply downloading the file, it should run it in Web Start.
Most major browsers support Java Web Start. Java Web Start is cross platform (works on Mac and PC).
So, in Javascript, it's done simply like this:
window.location = "http://www.examples.com/myapp.jnlp";
You'll also need to sign your Java application, or the user will get a nasty warning.
You should take a look at the Java Web Start technology.
This would be the closest thing: Java Web Start
Managing this through Applets is another option though the underlying scheme is the same, the user needs to accept the generated certificate.