Question:
I have an applet. I have successfully added the class to a JAR, but when the web page tries to load the applet, the browser gives us an error "can't find class file". When unzipping the JAR, my added class is present.
Answer:
Do not forget to add the "ARCHIVE" option to the APPLET tag like this
<applet code=my.class archive=archive.jar width=10 height=10>
</applet>
If "archive" is missing the browser will not know that your class is in a jar file...
Question:
Is there a way to write information to cookies through an Applet?
Answer:
Applets are not allowed to access information on the Client Side...it overrides the Sandbox
restriction...
However, JavaScript can access cookies and Java applet can talk to JavaScript.
So, a Java applet indirectly has access to cookies... An example of JavaScript <-->
Java was published in my newsletter before...
Look for the JSObject class from Netscape which works in IE as well.
Question:
I am writing a chat applet and I would like to put icons in user messages. Is it possible?
Answer:
A text area can parse HTML. Add image (jpg or gif) into html code and it will display your icons.
Question:
Can one applet load another applet on runtime, and can these two applets talk?
Answer:
the Answer found on "Internet related technologies" site:
"Yes one applet can load another applet. And since you need both the applet to communicate, you
need to have both applets in the same page. But the problem in this case is that both the applets will
load independently of each other. You can control the behaviour of the other applet from the first
one. But your requirement is of loading another applet from the first one.You can have two frames in
a page. In one frame there will be your first applet which will load automatically when the page is
loaded. And the other frame will contain a blank page. Now on certain event in the first applet you
can use "this.showDocument("URL") " to make a call to another applet which you want to load.
Give the target parameter as the other frame. (You will have to give the name of the other frame)
Now when these two applets are loaded they can exchange data in their life time."
http://www.springsource.com/landing/free-yourself-cost-complexity-limitations-heavyweight-app-servers?q=landing/free-yourself-cost-complexity-limitations-heavyweight-app-servers&_kk=java%20server&_kt=dca135b8-442b-4eb9-a46d-9b816bea2ad6&gclid=CMXV542UsqYCFQNrKgodbD7QoQ
Question:
How do I hide system properties that applets are allowed to read by default?
Answer:
There's no way to hide the ten system properties (see below) from applets loaded into a Java-
enabled browser. The reason is that the browsers don't consult any external files as part their Java
configuration, as a security precaution, including the
~/.hotjava/properties file.
From the appletviewer, you can prevent applets from finding out anything about your system by
redefining the property in your
~/.hotjava/properties file. For example, to hide the name of the operating system that you are using,
add this line to your
~/.hotjava/properties file:
os.name=null
Ten OS propertis that accessible by applet:
java.version
java.vendor
java.vendor.url
java.class.version
os.name
os.arch
os.version
file.separator
path.separator
line.separator
-
java
Tuesday, January 11, 2011
Monday, January 10, 2011
Till now we have gone through lot of java materials available in the market. I don't want to say this one is the best of all but i can surely say that this blog will contain the most essential java tips ever used by the effective programmers.
Question: What are restrictions for an applet? What are applets prevented from
doing?
Answer: In general, applets loaded over the net are prevented from reading and
writing files on the client file system, and from making network connections
except to the originating host.
In addition, applets loaded over the net are prevented from starting other
programs on the client. Applets loaded over the net are also not allowed to
load libraries, or to define native method calls. If an applet could define
native method calls, which would give the applet direct access to the
underlying computer.
è Question: How can my applet require some optional packages (specific vendor and
versions)?
Answer: Since version 1.3 Java introduced support for an expanded set of Jar-file
manifest attributes.
The following portion of a sample manifest file illustrates the attributes that are
available for use by optional packages.
Extension-Name: javax.help
Specification-Vendor: Sun Microsystems, Inc
Specification-Version: 1.0
Implementation-Vendor-Id: com.sun
Implementation-Vendor: Sun Microsystems, Inc
Implementation-Version: 1.0
Note that all of the above manifest attributes should be included in an optional
package's manifest. If the plug-in looks for but doesn't find one of these attributes in
an optional package's manifest, it will assume that the optional package is not
suitable for the applet.
Note: Optional packages are the new name for what used to be known as standard
extensions. The "extension mechanism" is that functionality of the Java 2 SDK and
Java 2 Runtime Environment that supports the use of optional packages.
Optional packages are packages of Java classes (and any associated native code)
that application developers can use to extend the functionality of the core platform.
The extension mechanism allows the Java virtual machine (VM) to use the classes of
Even More Tips at http://JavaA.com and http://JavaFAQ.nu every day!!!
Copyright © 2005 http://JavaA.com http://JavaFAQ.nu alex@javafaq.nu
the optional extension in much the same way as the VM uses classes in the Java 2
Platform. The extension mechanism also provides a way for needed optional
packages to be retrieved from specified URLs when they are not already installed in
the Java 2 SDK or Runtime Environment.
From SUN's description of the Java Extension Mechanism
è Good to know: Invoking modal popup dialogs from an applet's stop or destroy
methods is not recommended if you use Java 1.4.1 and below. Using modal popup
dialogs inside these methods could result in problematic behavior, including
NullPointerException, the dialog box not being displayed, the dialog box remaining
alive even after the applet was destroyed, or in the worst case, browser hang. This
problem has been fixed in 1.4.2.
è Question: Do I need special server software to use applets?
Answer: No. Java applets may be served by any HTTP server. On the server side
they are handled the same as any other file, such as a text, image, or sound file. All
the special action happens when the applet class files are interpreted on the client
side by a Java technology-enabled browser, such as HotJava browser or 1.x or
Netscape 3.x/4.x.
source: http://java.sun.com/products/jdk/faq.html#A8
è Question: I know that applets have limited possibility to do many things. It is about
network connections, file reading/writhing and more.
Can applet read all system properties and if not how many of them are restricted?
Answer: Applets can read quite many of system properties by using:
String ss = System.getProperty(String key):
java.version
java.vendor
java.vendor.url
java.class.version
os.name
os.arch
os.version
file.separator
path.separator
line.separator
Applets are prevented from reading these system properties:
java.home
java.class.path
user.name
user.home
user.dir
source: http://java.sun.com/sfaq/
doing?
Answer: In general, applets loaded over the net are prevented from reading and
writing files on the client file system, and from making network connections
except to the originating host.
In addition, applets loaded over the net are prevented from starting other
programs on the client. Applets loaded over the net are also not allowed to
load libraries, or to define native method calls. If an applet could define
native method calls, which would give the applet direct access to the
underlying computer.
è Question: How can my applet require some optional packages (specific vendor and
versions)?
Answer: Since version 1.3 Java introduced support for an expanded set of Jar-file
manifest attributes.
The following portion of a sample manifest file illustrates the attributes that are
available for use by optional packages.
Extension-Name: javax.help
Specification-Vendor: Sun Microsystems, Inc
Specification-Version: 1.0
Implementation-Vendor-Id: com.sun
Implementation-Vendor: Sun Microsystems, Inc
Implementation-Version: 1.0
Note that all of the above manifest attributes should be included in an optional
package's manifest. If the plug-in looks for but doesn't find one of these attributes in
an optional package's manifest, it will assume that the optional package is not
suitable for the applet.
Note: Optional packages are the new name for what used to be known as standard
extensions. The "extension mechanism" is that functionality of the Java 2 SDK and
Java 2 Runtime Environment that supports the use of optional packages.
Optional packages are packages of Java classes (and any associated native code)
that application developers can use to extend the functionality of the core platform.
The extension mechanism allows the Java virtual machine (VM) to use the classes of
Even More Tips at http://JavaA.com and http://JavaFAQ.nu every day!!!
Copyright © 2005 http://JavaA.com http://JavaFAQ.nu alex@javafaq.nu
the optional extension in much the same way as the VM uses classes in the Java 2
Platform. The extension mechanism also provides a way for needed optional
packages to be retrieved from specified URLs when they are not already installed in
the Java 2 SDK or Runtime Environment.
From SUN's description of the Java Extension Mechanism
è Good to know: Invoking modal popup dialogs from an applet's stop or destroy
methods is not recommended if you use Java 1.4.1 and below. Using modal popup
dialogs inside these methods could result in problematic behavior, including
NullPointerException, the dialog box not being displayed, the dialog box remaining
alive even after the applet was destroyed, or in the worst case, browser hang. This
problem has been fixed in 1.4.2.
è Question: Do I need special server software to use applets?
Answer: No. Java applets may be served by any HTTP server. On the server side
they are handled the same as any other file, such as a text, image, or sound file. All
the special action happens when the applet class files are interpreted on the client
side by a Java technology-enabled browser, such as HotJava browser or 1.x or
Netscape 3.x/4.x.
source: http://java.sun.com/products/jdk/faq.html#A8
è Question: I know that applets have limited possibility to do many things. It is about
network connections, file reading/writhing and more.
Can applet read all system properties and if not how many of them are restricted?
Answer: Applets can read quite many of system properties by using:
String ss = System.getProperty(String key):
java.version
java.vendor
java.vendor.url
java.class.version
os.name
os.arch
os.version
file.separator
path.separator
line.separator
Applets are prevented from reading these system properties:
java.home
java.class.path
user.name
user.home
user.dir
source: http://java.sun.com/sfaq/
Subscribe to:
Comments (Atom)