JavaScript to Java Communication - Packages Object in LiveConnect
In my previous post I explained about the JavaScript to Java Communication and the LiveConnect. Here I like to continue the with that. If a Java class is not part of the java, sun, or netscape packages, you access it with the Packages object. For example, suppose you created your own package like "org.eID.client.Desktop" which uses a Java package contain various Java classes like XMLparser.java, WSClient.java, ConnectTOApplication.java and ect.. ect.. that it implements for my project. To create an instance of the ConnectTOApplication class in org.eID.client.Desktop, you access the constructor of the class as follows: var red = new Packages.org.eID.client.Desktop.ConnectTOApplication(); You can also access classes in the default package (that is, classes that don't explicitly name a package). For example, if the HelloWorld class is directly in the CLASSPATH and not in a package, you can access it as follows: var helloWorld = new Packages.HelloWorld(); The LiveConnect java, sun, and netscape objects provide shortcuts for commonly used Java packages. For example, you can use the following: var myName = new java.lang.String("My name is Subanu"); instead of the longer version you can use like this : var myName = new Packages.java.lang.String("My name is Subanu"); I think this would definitely help you to understand how we can use the the Packages Object in LiveConnect. Enjoy :)
This Articles was posted on 8:04 PMFriday, January 9, 2009
|
Labels:
Experiences,
Firefox,
Java,
JavaScript,
Project work
|
0 comments:
Post a Comment