Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:35:44+00:00 2026-06-07T04:35:44+00:00

I have a Java applet on a webp age which I am trying to

  • 0

I have a Java applet on a webp age which I am trying to code against with Javascript.

public class WebCapture extends Applet {

  public String[] getSourceDeviceNames() {
    return new String[] {'Device 1', 'Device 2'};
  }

  public void acquireImage() {
    //...
  }

}

I compile this applet and supporting libraries into a jar file and it is included in my HTML page like so:

<embed id="webCaptureApplet"
 code="com.brian.webcapture.applets.WebCapture"
 archive="jar/WebCapture.jar"
 type="application/x-java-applet">

    <noembed>
      Oops! It looks like Java is not installed. =[
    </noembed>

</embed>  

This seems to be effective, I see a blank Java applet rendered to the screen and if I call

document.getElementById('webCaptureApplet');

I can alert() the object and receive a response [object HTMLEmbedElement]

Great. Now, when I try to execute the following code:

var applet = document.getElementById('webCaptureApplet');
var devices = applet.getSourceDeviceNames();

for(var i = 0; i < devices.length; i++) {
  alert(devices[i]);
}

When I attach a breakpoint to the line containing for() and inspect the object with firebug, the toString() value of devices is [Ljava.lang.String;@1d0b3465. I think this makes sense as an array is being passed back and it is not toString() friendly for showing a simple value.

When I look at devices.length in the foor loop, the value shown is the method stub for a public netscape.javascript.JSException(java.lang.String, java.lang.String, int, java.lang.String, int)

I have read countless how to’s on Javascript calling Java and I can not see where I have gone wrong with what seems to be pretty seamless interop.

I should say that at one point it was working through Firefox on OS X, but it is holding on to a cached applet, so I am confused what the problem is there. I have tried deleting my cache on both my work station and my laptop and they still seem to cling to old jar’s. I am not sure how much this is effecting me.

It seems to be that it does not make a difference if my applet’s getSourceDeviceNames returns a string or an array of strings. It will still show the same errors on inspection. I am not sure if the cache is effecting that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:35:46+00:00Added an answer on June 7, 2026 at 4:35 am

    According to http://www.uow.edu.au/~hasan/buss930/jscript/packages.htm#1014128
    “Java arrays are wrapped with a JavaScript object that understands array.length and array[index].”
    which works fine with Sun Java, but returns the JSException while running on OpenJDK.

    The only method I was able to find, is to count the elements of the array.

    var length = 0;
    while(array[length])
        length++;
    

    It seems, that this feature is buggy in OpenJDK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Java applet that loads native code through JNI. Everything worked just
I have written a java applet which opens a JFrame (so when run in
I have a Java applet embedded into a web page which generates a file
I have a Java Applet which takes two Parameters, X1 and X2. The applet's
I have a Java applet which displays an interactive map. By using the scroll
On a webpage I open a Java applet into another independent window. I have
I have a Java applet that is meant to run only on Windows. (It
I have a java applet for uploading files to server. I want to display
I have a java applet that draws top left x,y(0,0) to bottom right x,y(500,500).
in our application we have a Java applet running inside a .NET browser control.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.