Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 11th, 2006, 08:41 AM
Authorized User
 
Join Date: Oct 2006
Location: Jakarta, , Indonesia.
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


Reply With Quote
  #2 (permalink)  
Old October 11th, 2006, 01:37 PM
Friend of Wrox
 
Join Date: Jan 2006
Location: San Francisco, CA, USA.
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/
Reply With Quote
  #3 (permalink)  
Old October 11th, 2006, 11:02 PM
Authorized User
 
Join Date: Oct 2006
Location: Jakarta, , Indonesia.
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

Reply With Quote
  #4 (permalink)  
Old October 12th, 2006, 03:28 PM
Friend of Wrox
 
Join Date: Jan 2006
Location: San Francisco, CA, USA.
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/
Reply With Quote
  #5 (permalink)  
Old December 2nd, 2008, 10:49 PM
Authorized User
 
Join Date: Oct 2006
Location: Jakarta, , Indonesia.
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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 04:54 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.