Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crashing Applet (works in eclipse not in browser) 1

Status
Not open for further replies.

gh0st32

Programmer
Jan 24, 2008
8
US
Hi Everyone,

I wrote an applet that uses tabbedpanes and a sql connection. I wrote it in Eclipse, it complies and shows the applet in the eclipse browser but when I go to launch the applet in a web browser is fails to load. Would anyone be able to provide insight as to why this would happen.

The applet code is as follows (I gutted the code because it is really long)
Code:
import javax.swing.JButton;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JApplet;
import javax.swing.JComponent;
import java.awt.Dimension;
import javax.swing.JRadioButton;
import java.awt.*;
import javax.swing.*;
import java.awt.event.KeyEvent;
import javax.swing.border.*;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class tabbed_test_applet_09 extends JApplet implements ActionListener
		{

		private static final long serialVersionUID = 1L;
//class variables are declared here
		public void init() 
	    	{
//objects are added to the panels the panels are then added to the tabbed panes
}
public void actionPerformed(ActionEvent e)
	    {
//sql actions are carried out 
	    }
HTML is as follows
Code:
<html>
<head>

<title>Tabbed Test</title>
<head>
<body>
<APPLET CODE = "tabbed_test_applet_09.class" Width=600 Height=600></APPLET>
<body>
<html>


Thanks for you time!
 
I'd check the Java console to view the errors. Without that I can just guess: different Java version classpath problems ...

Btw, how do you launch it in Eclipse?

Cheers,
Dian
 
Hi Dian,

First let me thank you for looking into this. The console log is as follows

load: class tabbed_test_applet_09.class not found.
java.lang.ClassNotFoundException: tabbed_test_applet_09.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I have checked the file directory, the html file is in the same folder as the tabbed_test_applet_09.class file. I launch it in eclipse by running it as an applet.
 
I made some modifications, the reason why eclipse runs the applet is due to calls its own start()

explained here eclipse sdk

now the log shows

java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
at sun.applet.AppletSecurity.checkPackageAccess(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at tabbed_test_applet_09.updated_event_list(tabbed_test_applet_09.java:894)
at tabbed_test_applet_09.init(tabbed_test_applet_09.java:79)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

 
For security reasons, an applet cannot access network or local resources if it's not signed.

For testing purposes, you can control permissions via the java.policy file. This is an old but useful link that can show you the way.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top