Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning Java 2
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 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 July 1st, 2004, 07:12 AM
Registered User
 
Join Date: Jul 2004
Location: , Massachusetts, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sketcher Applet Problems

Hi,

I checked all the other postings to see if my problem had been addressed but didn't find anything. I've tried running the Sketcher applet both from Internet Explorer and from appletviewer without success.

I thought there might be an error in my code so I downloaded the sources from this website. Same result.

The error message in IE says the applet is notinited.

Can anybody help with this?

TIA.

Gerry Murphy
Reply With Quote
  #2 (permalink)  
Old July 2nd, 2004, 11:57 AM
Authorized User
 
Join Date: Sep 2003
Location: den Haag, , Netherlands.
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gerrymurphy
I've tried running the Sketcher applet both from Internet Explorer and from appletviewer without success.
Yes, but Sketcher is not an applet but an application. Because it is an application it can perform File input and output, so you can save the sketches you make, albeit in a Sketcher specific format (not GIF).

So how to get a first glance of the Sketcher we will build in the latter part of the book?

You open the MS-DOS screen (if you have a Windows platform).
Then you go to the directory where you stored the Sketcher.class file and the rest of the .class files you downloaded.
How to achieve this if you arre a beginner is not so easy either.
You type on the command line:

cd.. - to move to the parent directory
dir - to get an overview of the directory
cd dirname - to open another directory

OK so you arrived in the right directory, then:
java Sketcher - opens the Sketcher application

BUT you have to set the path to the
bin where the java (and javac, etc.)
in first place in the classpath,
else java cannot find any .class files

In the SDK documentation you will find how to set the classpath,
if you have done so you can check it in the AutoExec batch

Good luck
Francis @ chapter 15
it took me a few months only to get this matter right:
working in the MS-DOS screen and setting the classpath
oooch!
Reply With Quote
  #3 (permalink)  
Old July 8th, 2004, 06:11 AM
Registered User
 
Join Date: Jul 2004
Location: , Massachusetts, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks freezotic for replying, but I think you're missing the point.
Go back and look at your copy of the book. After creating the sketcher application the author next has an exercise to show how to convert it to an applet.

Reply With Quote
  #4 (permalink)  
Old July 8th, 2004, 07:54 AM
Authorized User
 
Join Date: Sep 2003
Location: den Haag, , Netherlands.
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gerrymurphy
 Thanks freezotic for replying, but I think you're missing the point.
Go back and look at your copy of the book.  After creating the sketcher application the author next has an exercise to show how to convert it to an applet.
Sorry, I should read better before typing the lot.
Let's see, so we convert Sketcher to an applet just to have an idea how an applet works compared to a regular application opening frames, I remember... Ivor told us there were some problems expected with the applet trying to open a new frame, which is not allowed, but that couldn't be the problem...?

Then what is it? Appletviewer does not recognize?

command line type (HTML!):
appletviewer sketcher.html
(.html file in current directory)

Applet not initialized? Why not? What's your code to do this?

Code:
import javax.swing.*;

public class Sketcher extends JApplet
{
  public static JApplet theApp;

  public static void main(String[] args)
  {
    theApp = this;
    theApp.init();
  }

  public void init()
  {
    // Sketcher code
  }
}
That would be the basics needed. Mind the static declaration!

The display of an applet in a browser need to have the Java plugin installed, if you haven't yet: go to my applet page and allow for the automatic install of the latest 1.4.2 plugin by Sun.

http://www.novaloka.nl/java/study/ch13ex7/lottery2.html

Everything fine now?
Tell me!
Francis
  
Reply With Quote
  #5 (permalink)  
Old July 8th, 2004, 01:02 PM
Registered User
 
Join Date: Jul 2004
Location: , Massachusetts, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Other applet examples in the text run without problems.
As I mentioned I tried downloading the source code from this website.
Doesn't run, either in a browser or with appletviewer.
Got to believe there's a problem in the example code.

Reply With Quote
  #6 (permalink)  
Old July 8th, 2004, 02:54 PM
Authorized User
 
Join Date: Sep 2003
Location: den Haag, , Netherlands.
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gerrymurphy
 Other applet examples in the text run without problems.
As I mentioned I tried downloading the source code from this website.
Doesn't run, either in a browser or with appletviewer.
Got to believe there's a problem in the example code.
Don't be shy!! post the example code of the Sketcher class that extends JApplet

:-)

But must say: these kind of things (total malfunctions) mostly are NOT bugs, but due to circumstantial things.

For instance: are all the other .class files the Sketcher.class applet uses present in the directory where you are running the appletviewer.
Is your command: appletviewer sketcherpage.html (.HTML!)
Does the .html file have the right code to run the applet?
You have to check this!
Is the bin set first in the classpath? (I always ask this)

Check it all, then come back and post all the codes for me to help you out!

Curiously yours
Francis Lelieveld
Holland
Reply With Quote
  #7 (permalink)  
Old July 8th, 2004, 04:44 PM
Registered User
 
Join Date: Jul 2004
Location: , Massachusetts, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code, as I mentioned, is availble on this website.
I don't think this is getting us anywhere so let's just drop it.
Thanks.

Reply With Quote
  #8 (permalink)  
Old August 26th, 2004, 11:30 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gerrymurphy
 The code, as I mentioned, is availble on this website.
I don't think this is getting us anywhere so let's just drop it.
Thanks.
Don't drop it. I'm having identical problem. I've followed the examples perfectly. TryApplet runs fine, it inits perfectly. Sketcher doesn't.

I *think* I have found some further information, though. If you bring up IE's java console (or, like me, run from linux appletviewer), you can see that there are some security violations (i *think*). Here's the result of my tests [appletviewer, under Debian w/Jdk 1.4~]

java.security.AccessCont********************ception: access denied (java.lang.RuntimePermission exitVM)
        at java.security.AccessControlContext.checkPermission (AccessControlContext.java:269)
        at java.security.AccessController.checkPermission(Acc essController.java:401)
        at java.lang.SecurityManager.checkPermission(Security Manager.java:524)
        at java.lang.SecurityManager.checkExit(SecurityManage r.java:736)
        at javax.swing.JFrame.setDefaultCloseOperation(JFrame .java:363)
        at SketchFrame.<init>(SketchFrame.java:9)
        at Sketcher.init(Sketcher.java:16)
        at sun.applet.AppletPanel.run(AppletPanel.java:353)
        at java.lang.Thread.run(Thread.java:534)




Reply With Quote
  #9 (permalink)  
Old August 28th, 2004, 05:33 AM
Authorized User
 
Join Date: Sep 2003
Location: den Haag, , Netherlands.
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is stupid!
Ivor Horton explains in the book, that you will have troubles creating a Frame (JFrame in this case) object from an applet (JApplet).
The example is meant to make you aware of problems like these!

Francis

Reply With Quote
  #10 (permalink)  
Old December 14th, 2004, 09:49 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello i am trying to create a clock applet on my page and all my specs and codeing is right i went over them accept when the page is loading it quits and says applet can't be initialized how do i fix this problem oh and i am using the latest of java.

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Spiral Sketcher freezotic BOOK: Beginning Java 2 0 September 4th, 2004 01:08 PM
Sketcher Full Source JCScoobyRS BOOK: Beginning Java 2 0 November 17th, 2003 02:18 PM
Sketcher Source JCScoobyRS Java GUI 1 November 17th, 2003 02:17 PM
drawing in java: sketcher koekke JSP Basics 0 October 25th, 2003 11:46 AM
sketcher koekke Wrox Book Feedback 1 October 20th, 2003 09:43 AM



All times are GMT -4. The time now is 07:21 AM.


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