Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 11th, 2006, 08:41 AM
Authorized User
 
Join Date: Oct 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Nicholsen
Default Help

Hello everybody
 I have a question about compiling java applet. The problem is:
import java.awt.*;
import javax.swing.*;

public class BubbleSort extends JApplet {

   // inisialisasi applet
   public void init()
   {
      JTextArea outputArea = new JTextArea();
      Container container = getContentPane();
      container.add( outputArea );

      int array[] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 };

      String output = "Data items in original order\n";

      for ( int counter = 0; counter < array.length; counter++ )
         output += " " + array[ counter ];

      bubbleSort( array ); // sort array

      output += "\n\nData items in ascending order\n";

      for ( int counter = 0; counter < array.length; counter++ )
         output += " " + array[ counter ];

      outputArea.setText( output );

   }
   public void bubbleSort( int array2[] )
   {
      for ( int pass = 1; pass < array2.length; pass++ ) {

         for ( int element = 0;
               element < array2.length - 1;
               element++ ) {

            if ( array2[ element ] > array2[ element + 1 ] )
               swap( array2, element, element + 1 );

         }
      }

   }


   public void swap( int array3[], int first, int second )
   {
      int hold;

      hold = array3[ first ];
      array3[ first ] = array3[ second ];
      array3[ second ] = hold;
   }

}
I compile it with Internet explorer, with the code:
<html>
<applet code = BubbleSort.class" width = "300" height="45">
</applet>
</html>
I already make BubbleSort.class.
The error are:
basic: Registered modality listener
liveconnect: Invoking JS method: document
liveconnect: Invoking JS method: URL
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@10655dd, refcount=1
basic: Added progress listener: sun.plugin.util.GrayBoxPainter@860d49
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...
load: class BubbleSort.class" not found.
java.lang.ClassNotFoundException: BubbleSort.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)
Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_07\BubbleSort\class".class (The system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connec t(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInp utStream(Unknown Source)
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more
basic: Exception: java.lang.ClassNotFoundException: BubbleSort.class"
java.lang.ClassNotFoundException: BubbleSort.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)
Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_07\BubbleSort\class".class (The system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connec t(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInp utStream(Unknown Source)
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more
basic: Modality pushed
basic: Modality popped.

I compile it on DOS prompt too with appletviewer BubbleSort.html, but I have the same error message. Can anyone help me to solve my problem.
For all of this, I said Thank You Very Much


 
Old October 11th, 2006, 01:37 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, without spending too much time reproducing the issue here, I can immediately tell that your quotes don't match up in your <applet> tag for the code attribute. How about trying this instead?

<applet code="BubbleSort.class" width="300" height="45">

Jon Emerson
http://www.jonemerson.net/
 
Old October 11th, 2006, 11:02 PM
Authorized User
 
Join Date: Oct 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Nicholsen
Default

Thank You. I will try it, but is there any other way to compile it, because I can't compile it in DOS prompt.Thank You

 
Old October 12th, 2006, 03:28 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should be able to compile it from the command line if you have your classpath properly configured. What errors are you getting?

Jon Emerson
http://www.jonemerson.net/
 
Old December 2nd, 2008, 11:49 PM
Authorized User
 
Join Date: Oct 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Nicholsen
Default

Thank You for Your answer.
I really appreciate it.










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.