Applet abends!!!
I am completely new to applets! There are absolutely no errors shown, but the game abends every time I try to determine whether or not the user wins or loses. This is the main mehtod and the two constructors:
// User is asked to guess which of the two face down cards has
// the greatest value. The face value is the only thing used to
// determine the value of the cards. When the user selects a card,
// the fronts of the cards are shown, and the result of the game is
// displayed. The user is aksed if he or she wishes to play again.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Exercise4 extends Applet implements MouseListener
DeckOfCards deck;
Card card1, card2, drawnCard1, drawnCard2;
String result, message, programmerName = "2";
Font bigFont;
Image cardpics; by-60
public void init()
setBackground( Color.cyan );
setSize (320,250);
addMouseListener(this);
cardpics = getImage(getCodeBase(), "cards.gif");
bigFont = new Font("Serif", Font.BOLD, 14);
deck = new DeckOfCards();
deal();
// Start the game by dealing two cards and repainting the applet.
void deal()
card1 = card2 = drawnCard1 = drawnCard2 = null;
message = "Which Card is Higher?";
result = "";
deck.shuffle();
deck.deal();
repaint();
// Because the applet is registered to listen for mouse clicks on
// itself, the system will call this method when the user presses
// the mouse on the applet. In this case, the method checks whether
// the user clicked on one of the cards or on the message at the
// bottom of the screen. If the user clicked card N, this method
// calls clickedCard(N). If the user clicked on the message, this
// method calls clickedMessage().
public void mousePressed(MouseEvent evt)
int x = evt.getX(); // convenient name for x-coord of mouse
int y = evt.getY(); // convenient name for y-coord of mouse
if ( y > 20 && y < 80 )
if (x > 100 && x < 140)
clickedCard(1);
else if (x > 160 && x < 200)
clickedCard(2);
else
if (x > 33 && x > 25)
deal();
// This method is called (by the mousePressed() method given below)
// when the user clicks on one of the cards. The parameter, cardNum,
// tells which card was clicked. String result is set to the appropriate
// message telling the outcome of the game.
void clickedCard(int cardNum)
cardNum = card1.getValue();
if (card1.getValue() > card2.getValue())
message = "You win!";
else if (card1.getValue() < card2.getValue())
message = "Too Bad - You Lose";
else if (card1.getValue() == card2.getValue())
message = "A Draw";
drawnCard1 = card1;
drawnCard2 = card2;
message = "Play Again?";
repaint();
// The paint method is called by the system when the applet needs
// to be repainted. In this applet, it draws the two cards
// and the messages at the bottom of the applet.
public void paint(Graphics g)
int width = getSize().width;
int height = getSize().height;
FontMetrics fm = getFontMetrics(bigFont);
int w;
g.setColor(Color.blue);
g.drawRect(0,0,width-1,height-1);
g.setColor(Color.pink); background.
g.fillRect(33, 105, 250, 25);
g.setColor(Color.blue);
g.drawRect(33, 105, 250, 25);
g.setFont( bigFont );
w = fm.stringWidth(message);
g.drawString( message, 86, 122);
g.setColor(Color.pink);
g.fillRect(33, 155, 250, 25);
g.setColor(Color.blue);
g.drawRect(33, 155, 250, 25);
g.setFont( bigFont );
w = fm.stringWidth(result);
g.drawString( result, 20, 30);
g.setColor(Color.pink);
g.fillRect(33, 205, 250, 25);
g.setColor(Color.blue);
g.drawRect(33, 205, 250, 25);
g.setFont( bigFont );
w = fm.stringWidth(programmerName);
g.drawString( programmerName, 65, 222);
drawCard( g, drawnCard1, 100, 20 ); // Draw the two cards.
drawCard( g, drawnCard2, 160, 20 ); // If drawnCard1 or drawnCard2 are null,
// the cards will be drawn face down.
// Draws a card as a 40 by 60 rectangle with
// upper left corner at (x,y). The card is drawn
// in the graphics context g. If card is null, then
// a face-down card is drawn.
void drawCard(Graphics g, Card card, int x, int y)
if (card == null)
// Draw a face-down card
g.setColor(Color.blue);
g.fillRect(x,y,40,60);
g.setColor(Color.white);
g.drawRect(x+3,y+3,33,53);
g.drawRect(x+4,y+4,31,51);
else
int row = 0;
switch (card.getSuit())
case 0: row = 0; break;
case 1: row = 1; break;
case 2: row = 2; break;
case 3: row = 3; break;
int sx, sy; // coords of upper left corner in the source image.
sx = 40*(card.getValue() - 1);
sy = 60*row;
g.drawImage(cardpics, x, y, x+40, y+60,
sx, sy, sx+40, sy+60, this);
// Other mouse routines required by the MouseListener interface.
// They are not used in this applet
public void mouseClicked(MouseEvent evt) { }
public void mouseReleased(MouseEvent evt) { }
public void mouseEntered(MouseEvent evt) { }
public void mouseExited(MouseEvent evt) { }
// DeckOfCards.java
import java.util.Random;
public class DeckOfCards
private int count;
private boolean[] deck = new boolean[53];
Random generator = new Random();
public DeckOfCards()
shuffle();
public void shuffle()
for (int i = 1; i <= 52; i++)
deck[i] = false;
count = 0;
public Card deal()
int num, suit;
if (count > 51)
num = -1;
suit = -1;
else
do
num = generator.nextInt(13) + 1;
suit = generator.nextInt(4);
while (deck[num+suit*13] == true);
deck[num+suit*13] = true;
count++;
return new Card(num,suit);
public int cardsInDeck()
return (52 - count);
// Card.java
public class Card
private int num, suit;
public Card (int num, int suit)
this.num = num;
this.suit = suit;
public int getValue ()
return num;
public int getSuit ()
return suit;
public String toString()
String result = "message";
switch (num)
case -1: result = " No Card"; break;
case 1: result = " Ace "; break;
case 2: result = " 2 "; break;
case 3: result = " 3 "; break;
case 4: result = " 4 "; break;
case 5: result = " 5 "; break;
case 6: result = " 6 "; break;
case 7: result = " 7 "; break;
case 8: result = " 8 "; break;
case 9: result = " 9 "; break;
case 10: result = " 10 "; break;
case 11: result = " Jack "; break;
case 12: result = " Queen"; break;
case 13: result = " King "; break;
switch (suit)
case -1: break;
case 0: result = result + " of Clubs"; break;
case 1: result = result + " of Hearts"; break;
case 2: result = result + " of Spades"; break;
case 3: result = result + " of Diamonds"; break;
return result;
}
"Abends"? What does that mean?
Anyway, try writing a smallest possible applet that exhibits the behavior you're seeing. That'll be easier to debug. If you can't debug it yourself, then ask again here. Ask about the smallest possible applet, though; you'll tend to scare people away with long programs posted here. When you post code, always wrap it in [code][/code] tags so it's legible; ugly unformatted code will also scare people away.
Similar Messages
-
Problem with threads within applet
Hello,
I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
this thread is running in endless loop.
he is doing something and go to sleep on and on.
the problem is,
when I refresh my IE6 browser I see more than 1 thread.
for debug matter, I did the following things:
inside the thread, sysout every time he goes to sleep.
sysout in the singleton constructor.
sysout in the singleton destructor.
the output goes like this:
when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
The destructor never works (no output there).
I don't understand what is going on.
someone can please shed some light?
thanks.
btw. I am working with JRE 1.1
this is very old and big applet and I can't convert it to something new.Ooops. sorry!
I did.
public void start() {
public void stop() {
public void destroy() {
try {
resetAll();
Configuration.closeConnection();
QuoteItem.closeConnection();
} finally {
try {
super.finalize();
} catch (Throwable e) {
e.printStackTrace();
} -
I'm developing an applet that has to open some web pages.
The only way I know is to use the method showDocument that
needs and URL. So, how to pass parameters to the web page?
I don't want to put them in the URL: everyone can see
"secret data"!
Help me, please.Take a look at this example that uses a JEditor pane to hold the HTML page.
//Create a new JEditor Pane
jep = new JEditorPane( );
//Ensure the pane is not editable
jep.setEditable(false);
//Use this to get local HTML file
URL fileURL = this.getClass().getResource("Manual/Manual.htm");
//add the html page to the JEditorPane
jep.setPage(fileURL);Ok the core line of code here is this.
URL fileURL = this.getClass().getResource("Manual/Manual.htm");The standard method for accessing a html file via a URL is thus. As you can see its very similar.
URL fileURL = new URL("http://www.comp.glam.ac.uk/pages/staff/asscott/progranimate/docs/Manual/Manual.htm");this.getClass().getResourse() will return the file location of the class you are working with.
By doing the following you can access manual.html in a folder called Manual that sits in the same file location as the class file you are using.
URL fileURL = this.getClass().getResource("Manual/Manual.htm");I hope this helps.
Andrew. -
Unable to load database driver from my applet's jar file
I'm trying to set up an applet that will talk to a MySQL database. I have no problem connecting to the database as I'm developing the code ("un-jarred"), but when I create a jar file of my code to test through a web browser, I cannot connect to the database due to the usual ClassNotFoundException. I have included mysql-connector-java-3.1.12-bin.jar (the current driver) in the jar, but I don't know if I'm supposed to supply some info through an attribute to the applet tag to let it know that the jar contains the driver it needs or if I have to call the driver differently in my code.
Any help is appreciated, thanks.The simplest approach is always the best. :)Abso-lutely.
Awesome, that worked perfectly. I Included the extra
jar file in the applet tag and now my applet makes
some sweet lovin' to the database.And you have succeeded where thousands have failed. Congratulations. -
Applet java file not refreshing in browser
I have an applet that I am updating and I am not seeing the corresponding update when I open the web page. I can manually download the java class file and look inside it and it definitely is the updated file. I have deleted the browser history. (I am running tests with Firefox 3, IE7, and Safari 4 public beta). Is there something else I need to do to make sure the browser pulls in the latest version of the class file referenced in the html?
Here is the code:
<HTML>
<HEAD>
<TITLE>A Simple Program</TITLE>
</HEAD>
<BODY>
<CENTER>
<APPLET CODE="SendRequest.class" WIDTH="500" HEIGHT="150">
</APPLET>
</CENTER>
</BODY>
</HTML>The applet refers to a hard coded URL to read through a urlconnection. It is always reading a file and showing content, but it is not showing the right file. If I change the name of the referenced file in the java program, it looks like the browser has cached the referred file, rather than throwing and error and saying the file doesn't exist.
Here is the java
import java.applet.*;
import java.awt.*;
import java.net.URLConnection;
import java.net.URL;
import org.w3c.dom.Document;
import java.lang.String;
import java.io.*;
public class SendRequest extends Applet {
@Override
public void paint(Graphics g) {
g.drawRect(0, 0, 499, 149);
g.drawString(getResponseText(), 5, 70);
public String getResponseText() {
try {
URL url = new URL("http://myserver.com/stats/logs/ex20090603000001-72.167.131.217.log");
URLConnection urlconn = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
urlconn.getInputStream()));
String inputLine;
String htmlFile = "";
try {
while ((inputLine = in.readLine()) != null)
htmlFile += inputLine;
in.close();
return htmlFile;
} catch (Exception e) {
return "Can't get the string.";
} catch (Exception e) {
return "Problem accessing the response text.";
}Any help would be appreciated. I heard that some files may cache more persistently than others, but I don't fully understand the details.
Thanks,
JimCheck this [document loader example|http://pscode.org/test/docload/] & follow the link to sandbox.html for tips on clearing the class cache. That relates specifically to caching a refused security certificate, but class caching is much the same. As an aside, getting a console can be tricky in modern times (unless the applet fails completely). It is handy to configure the [Java Control Panel|http://java.sun.com/docs/books/tutorial/information/player.jnlp] to pop the Java console on finding an applet (Advanced tab - Settings/Java Console/Show Console).
Of course there are two better tools for testing applets, especially in regard to class caching. AppletViewer and Appleteer both make class refresh fairly easy. Appleteer is the better of the two. I can tell you that with confidence, since I wrote it. ;-) -
EJB 3.0 - Communicate an Applet with a Session Bean
Hello
I'm developing an EJB 3.0 app (eclipse and glassfish tools bundle), and I have an applet that has to use remote session beans.
QUESTION: Is it possible for the applet to connect to EJB?
QUESTION: By creating a J2EE application client project, can I use @EJB annotations to inject the session bean directly to the applet, avoiding the JNDI lookup?
(since I imagine that the anwser to the second one is NO, I do the following consideration)
Given an application client project, I imagine that this application can run remotely on a client machine/JRE. Then this application can use Annotations/injection facilities whenever it runs on a J2EE client container (which I assume consists of a set of libraries provided by the application server vendor, Glassfish in that case). Could this application be deployed using Java Web Start? If so, why can't it be deployed as an applet? (both options run in a client JRE, don't they?).
QUESTION: In either case (applet or JWS), how do I have to package the JAR file (using Eclipse) so that it contains the needed libraries for accessing the EJB? Which are those libraries?
At the time being, I'm trying to implement a sample application that follows the "Applet doing JNDI lookup" approach. I have:
- an EAR project
- an EJB project (containing an Entity Bean and a Stateless Session Bean with a @Remote interface)
@Remote
public interface HelloRemote {
public String hello(String name);
@Stateless
public class Hello implements HelloRemote {
@Override
public String hello(String name) {
return "Hello "+name+"!!";
}- an Application Client project (containing the applet code):
public class ClientApplet extends JApplet {
public void init(){
try {
Context jndiContext = getInitialContext( );
HelloRemote server = (HelloRemote) jndiContext.lookup(HelloRemote.class.getName());
setContentPane(new JLabel(server.hello("Gerard")));
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
private Context getInitialContext() throws NamingException{
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "myhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
return new InitialContext(props);
}- a static web project (with a sample web page that contains the applet object the corresponding applet JAR file)
I tried to export the Application Client project as an "application client JAR", in the hope that the java EE libraries bundled with glassfish (listed as libraries of this project) would be packaged too.
No success, so now I'll try to copy all the JAR files (one by one) into the +\WebContent\+ folder of the Web Project, and add references to each of them in the archive="" attribute of the +<applet>+ HTML tag. Although this might work, I suspect that I am missing the good/easy way of doing it. Any suggestions?
Thanks in advance,
Gerard
Edited by: gsoldevila on May 6, 2009 7:09 AMAn Applet can communicate with an EJB via JNDI lookup but I would (personally) use an intermediate Servlet to handle this. Client to Servlet communication is http whereas to ejb is iiop - which might be blocked.
Injection only works in managed classes (EJB, Servlet, Listeners..) and an Application Client main class. So yes you could use an app client for handling resource injection.
m -
Error while accessing a public method of applet from javascript.
Hi,
I am getting "Object doesn't support this property or method" error
when accessing a public method of applet from javascript in IE 6 using
document.applets[0].myMethod();
The same is working in IE 7.
Thanks in advance.
Regards,
PhanikanthI don't know why it happens, but this works for me in both versions:
<applet ..... name="MyApplet">
</applet>and in javascript use
document.MyApplet.myMethod() -
Can not view applet in browser (IE5.5)
only my appletviewer shows my very simple applet.
in the IE5.5 i can not view my applet... ?
my applet just have write a string...
any help ?http://forum.java.sun.com/thread.jsp?forum=31&thread=276607
-
A function can not be used in Applet.what's wrong?
Here is a function.
private String LoadFile() {
String input;
String output="sssssdsdsddf";
try{
FileReader f=new FileReader("shu.txt");
BufferedReader in = new BufferedReader(f);
while ((input = in.readLine())!= null){output=output+input;}
in.close();
}catch(IOException e) {
System.err.println("Exception caught: " + e.getMessage());
return output;
It can be used in Java Application,and work well.but can not be used in Applet,it does not work.what's wrong?http://www.javaworld.com/javaworld/jw-12-2000/jw-1215-security.html#sidebar1
-
A function can not be used in Applet.what' wrong?
Here is a function.
private String LoadFile() {
String input;
String output="sssssdsdsddf";
try{
FileReader f=new FileReader("shu.txt");
BufferedReader in = new BufferedReader(f);
while ((input = in.readLine())!= null){output=output+input;}
in.close();
}catch(IOException e) {
System.err.println("Exception caught: " + e.getMessage());
return output;
It can be used in Java Application,and work well.but can not be used in Applet,it does not work.what's wrong?Don't you think it would be a bit of a security risk if any applet you downloaded from the web (unknowingly) could read/write to your file system....
Applets have strict security applied to them, and file i/o is one of the restrictions. There are ways around it, but for the moment I'd suggest you build a bridge and get over it.
Cheers,
Radish21 -
Unable to delete applet.....
Hi all,
I am unable to delete one applet which I have loaded in the card.
There are 2 applets, one is purse and other is loyalty. And am using shareable interface in which loyalty is the server and purse is the client. I can delete the purse applet but i can't delete the loyalty from the card.
Here is my code : There are in all 3 codes, one is purse, second is loyalty code and third is the shareable interface code. Can some one look at the code and tell me what's wrong in this programs.
package com.gemplus.examples.loyalty;
import javacard.framework.*;
import visa.openplatform.*;
public class Loyalty extends javacard.framework.Applet implements TestInterface
static byte points ;
protected Loyalty(byte[] buffer, short offset, byte length)
// data offset is used for application specific parameter.
// initialization with default offset (AID offset).
short dataOffset = offset;
if(length > 9) {
// Install parameter detail. Compliant with OP 2.0.1.
// | size | content
// |------|---------------------------
// | 1 | [AID_Length]
// | 5-16 | [AID_Bytes]
// | 1 | [Privilege_Length]
// | 1-n | [Privilege_Bytes] (normally 1Byte)
// | 1 | [Application_Proprietary_Length]
// | 0-m | [Application_Proprietary_Bytes]
// shift to privilege offset
dataOffset += (short)(1 + buffer[offset]);
// finally shift to Application specific offset
dataOffset += (short)(1 + buffer[dataOffset]);
// checks wrong data length
if(buffer[dataOffset] != 4)
// return received proprietary data length in the reason
ISOException.throwIt((short)(ISO7816.SW_WRONG_LENGTH + offset + length - dataOffset));
// go to proprietary data
dataOffset++;
// points = 0;
// register this instance
register(buffer, (short)(offset + 1), (byte)buffer[offset]);
* Method installing the applet.
* @param bArray the array constaining installation parameters
* @param bOffset the starting offset in bArray
* @param bLength the length in bytes of the data parameter in bArray
public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException
/* applet instance creation */
new Loyalty (bArray, bOffset, (byte)bLength);
* Select method returning true if applet selection is supported.
* @return boolean status of selection.
public boolean select()
/* return status of selection */
return true;
* Deselect method.
public void deselect()
return;
public void process(APDU apdu) throws ISOException
// check valid Applet state
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
apdu.setIncomingAndReceive();
byte[] apduBuffer = apdu.getBuffer();
// writes the balance into the APDU buffer after the APDU command part
creditPoints((byte)0x00);
apduBuffer[5] = (byte)(points >> 8) ;
apduBuffer[6] = (byte)points ;
// sends the APDU response
// switches to output mode
apdu.setOutgoing() ;
// 2 bytes to return
apdu.setOutgoingLength((short)2) ;
// offset and length of bytes to return in the APDU buffer
apdu.sendBytes((short)5, (short)2) ;
public void creditPoints(byte pTobeCredited)
points += pTobeCredited;
public Shareable getShareableInterfaceObject(AID client, byte param){
if(param != (byte)0x00)
return null;
return (this);
second code is :
package com.gemplus.examples.oppurse;
* Imported packages
import javacard.framework.*;
import visa.openplatform.*;
import com.gemplus.examples.loyalty.*;
public class OPPurse extends javacard.framework.Applet
// the APDU constants for all the commands.
private final static byte INS_GET_BALANCE = (byte)0x30 ;
private final static byte INS_DEBIT = (byte)0x31 ;
private final static byte INS_CREDIT = (byte)0x32 ;
private final static byte INS_VERIFY_PIN = (byte)0x33 ;
private final static byte INS_SET_NAME = (byte)0x34 ;
private final static byte INS_GET_NAME = (byte)0x35 ;
// the OP/VOP specific instruction set for mutual authentication
private final static byte CLA_INIT_UPDATE = (byte)0x80 ;
private final static byte INS_INIT_UPDATE = (byte)0x50 ;
private final static byte CLA_EXTERNAL_AUTHENTICATE = (byte)0x84 ;
private final static byte INS_EXTERNAL_AUTHENTICATE = (byte)0x82 ;
// the PIN validity flag
private boolean validPIN = false;
// SW bytes for PIN Failed condition
// the last nibble is replaced with the number of remaining tries
private final static short SW_PIN_FAILED = (short)0x63C0;
private final static short SW_FAILED_TO_OBTAIN_SIO = (short)0x63D0;
private final static short SW_LOYALTY_APP_NOT_EXIST = (short)0x63E0;
// the illegal amount value for the exceptions.
private final static short ILLEGAL_AMOUNT = 1;
// the maximum balance in this purse.
private static final short maximumBalance = 10000;
// the current balance in this purse.
private static short balance;
/* byte[] loyaltyAID = new byte[]{ (byte)0xA0,(byte)0x00,(byte)0x00,(byte)0x00,
(byte)0x19,(byte)0xFF,(byte)0x00,(byte)0x00,
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
(byte)0x00,(byte)0x00,(byte)0x02,(byte)0x02};*/
/* Security part of declarations */
// the Security Object necessary to credit the purse
private ProviderSecurityDomain securityObject = null;
// the security channel number
byte secureChannel = (byte)0xFF;
// the authentication status
private boolean authenticationDone = false;
// the secure channel status
private boolean channelOpened = false;
private byte[] nameBuffer = new byte[6];
* Only this class's install method should create the applet object.
protected OPPurse(byte[] buffer, short offset, byte length)
// data offset is used for application specific parameter.
// initialization with default offset (AID offset).
short dataOffset = offset;
if(length > 9) {
// Install parameter detail. Compliant with OP 2.0.1.
// | size | content
// |------|---------------------------
// | 1 | [AID_Length]
// | 5-16 | [AID_Bytes]
// | 1 | [Privilege_Length]
// | 1-n | [Privilege_Bytes] (normally 1Byte)
// | 1 | [Application_Proprietary_Length]
// | 0-m | [Application_Proprietary_Bytes]
// shift to privilege offset
dataOffset += (short)( 1 + buffer[offset]);
// finally shift to Application specific offset
dataOffset += (short)( 1 + buffer[dataOffset]);
// checks wrong data length
if(buffer[dataOffset] != 2)
// return received proprietary data length in the reason
ISOException.throwIt((short)(ISO7816.SW_WRONG_LENGTH + offset + length - dataOffset));
// go to proprietary data
dataOffset++;
} else {
// Install parameter compliant with OP 2.0.
if(length != 2)
ISOException.throwIt((short)(ISO7816.SW_WRONG_LENGTH + length));
// retreive the balance value from the APDU buffer
short value = (short)(((buffer[(short)(dataOffset + 1)]) & 0xFF)
| ((buffer[dataOffset] & 0xFF) << 8));
// checks initial balance value
if(value > maximumBalance)
ISOException.throwIt(ISO7816.SW_DATA_INVALID);
// initializes the balance with the APDU buffer contents
balance = value;
// register this instance as an installed Applet
register();
// ask the system for the Security Object associated to the Applet
securityObject = OPSystem.getSecurityDomain();
// applet is personalized and its state can change
OPSystem.setCardContentState(OPSystem.APPLET_PERSONALIZED);
// build the new ATR historical bytes
byte[] newATRHistory = new byte[]
// put "OPPurse" in historical bytes.
(byte)0x4F, (byte)0x50, (byte)0x50, (byte)0x75, (byte)0x72, (byte)0x73, (byte)0x65
// !!! ACTIVATED IF INSTALL PRIVILEGE IS "Default Selected" (0x04). !!!
// change the default ATR to a personalized's one
OPSystem.setATRHistBytes(newATRHistory, (short)0, (byte)newATRHistory.length);
* Method installing the applet.
* @param installparam the array constaining installation parameters
* @param offset the starting offset in installparam
* @param length the length in bytes of the data parameter in installparam
public static void install(byte[] installparam, short offset, byte length )
throws ISOException
// applet instance creation with the initial balance
new OPPurse(installparam, offset, length );
* Select method returning true if applet selection is supported.
* @return boolean status of selection.
public boolean select()
validPIN = false;
// reset security if used.
// In case of reset deselect is not called
reset_security();
// return status of selection
return true;
* Deselect method.
public void deselect()
// reset security if used.
reset_security();
return;
* Method processing an incoming APDU.
* @see APDU
* @param apdu the incoming APDU
* @exception ISOException with the response bytes defined by ISO 7816-4
public void process(APDU apdu) throws ISOException
// get the APDU buffer
// the APDU data is available in 'apduBuffer'
byte[] apduBuffer = apdu.getBuffer();
// the "try" is mandatory because the debit method
// can throw a javacard.framework.UserException
try
switch(apduBuffer[ISO7816.OFFSET_INS])
case INS_VERIFY_PIN :
verifyPIN(apdu);
break ;
case INS_GET_BALANCE :
getBalance(apdu) ;
break ;
case INS_DEBIT :
debit(apdu) ;
break ;
case INS_SET_NAME :
setName(apdu);
break;
case INS_GET_NAME :
getName(apdu);
break ;
case INS_CREDIT :
credit(apdu) ;
break ;
case INS_INIT_UPDATE :
if(apduBuffer[ISO7816.OFFSET_CLA] == CLA_INIT_UPDATE)
// call initialize/update security method
init_update(apdu) ;
else
// wrong CLA received
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
break ;
case INS_EXTERNAL_AUTHENTICATE :
if(apduBuffer[ISO7816.OFFSET_CLA] == CLA_EXTERNAL_AUTHENTICATE)
// call external/authenticate security method
external_authenticate(apdu) ;
else
// wrong CLA received
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
break ;
case ISO7816.INS_SELECT :
break ;
default :
// The INS code is not supported by the dispatcher
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED) ;
break ;
} // end of the switch
} // end of the try
catch(UserException e)
// translates the UserException in an ISOException.
if(e.getReason() == ILLEGAL_AMOUNT)
throw new ISOException ( ISO7816.SW_DATA_INVALID ) ;
//- P R I V A T E M E T H O D S -
* Handles Verify Pin APDU.
* @param apdu APDU object
private void verifyPIN(APDU apdu)
// get APDU data
apdu.setIncomingAndReceive();
// get APDU buffer
byte[] apduBuffer = apdu.getBuffer();
// check that the PIN is not blocked
if(OPSystem.getTriesRemaining() == 0)
OPSystem.setCardContentState(OPSystem.APPLET_BLOCKED);
// Pin format for OP specification
// |type(2),length|nible(1),nible(2)|nible(3),nible(4)|...|nible(n-1),nible(n)|
// get Pin length
byte length = (byte)(apduBuffer[ISO7816.OFFSET_LC] & 0x0F);
// pad the PIN ASCII value
for(byte i=length; i<0x0E; i++)
// only low nibble of padding is used
apduBuffer[ISO7816.OFFSET_CDATA + i] = 0x3F;
// fill header TAG
apduBuffer[0] = (byte)((0x02 << 4) | length);
// parse ASCII Pin code
for(byte i=0; i<0x0E; i++)
// fill bytes with ASCII Pin nibbles
if((i & 0x01) == 0)
// high nibble
apduBuffer[(i >> 1)+1] = (byte)((apduBuffer[ISO7816.OFFSET_CDATA + i] & 0x0F) << 4);
else
// low nibble
apduBuffer[(i >> 1)+1] |= (byte)(apduBuffer[ISO7816.OFFSET_CDATA + i] & 0x0F);
// verify the received PIN
// !!! WARNING PIN HAS TO BE INITIALIZED BEFORE USE !!!
if(OPSystem.verifyPin(apdu, (byte)0))
// set PIN validity flag
validPIN = true;
// if applet state is BLOCKED then restore previous state (PERSONALIZED)
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
OPSystem.setCardContentState(OPSystem.APPLET_PERSONALIZED);
return;
// the last nibble of returned code is the number of remaining tries
ISOException.throwIt((short)(SW_PIN_FAILED + OPSystem.getTriesRemaining()));
* Performs the "getBalance" operation on this counter.
* @param apdu The APDU to process.
private void getBalance( APDU apdu )
// check valid Applet state
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
// get the APDU buffer
byte[] apduBuffer = apdu.getBuffer();
// writes the balance into the APDU buffer after the APDU command part
apduBuffer[5] = (byte)(balance >> 8) ;
apduBuffer[6] = (byte)balance ;
// sends the APDU response
// switches to output mode
apdu.setOutgoing() ;
// 2 bytes to return
apdu.setOutgoingLength((short)2) ;
// offset and length of bytes to return in the APDU buffer
apdu.sendBytes((short)5, (short)2) ;
private void setName(APDU apdu)
// check valid Applet state
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
// the operation is allowed only if master pin is validated
if(!validPIN)
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
byte[] apduBuffer = apdu.getBuffer();
apdu.setIncomingAndReceive();
for(short i=0,k=5;i<6;i++,k++)
nameBuffer[i] = apduBuffer[k];
}//end of setName
private void getName(APDU apdu)
// check valid Applet state
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
byte[] apduBuffer = apdu.getBuffer();
for(short i=5, k=0;i<11;i++,k++)
apduBuffer=nameBuffer[k];
apdu.setOutgoing();
apdu.setOutgoingLength((short)6);
apdu.sendBytes((short)5,(short)6);
}//end of storeName
* Performs the "debit" operation on this counter.
* @param apdu The APDU to process.
* @exception ISOException If the APDU is invalid.
* @exception UserException If the amount to debit is invalid.
private void debit(APDU apdu) throws ISOException, UserException
// check valid Applet state
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
// the operation is allowed only if master pin is validated
if(!validPIN)
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
// get the APDU buffer
byte[] apduBuffer = apdu.getBuffer();
// Gets the length of bytes to recieved from the terminal and receives them
// If does not receive 4 bytes throws an ISO.SW_WRONG_LENGTH exception
if(apduBuffer[4] != 2 || apdu.setIncomingAndReceive() != 2)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH) ;
// Reads the debit amount from the APDU buffer
// Starts at offset 5 in the APDU buffer since the 5 first bytes
// are used by the APDU command part
short amount = (short)(((apduBuffer[6]) & (short)0x000000FF)
| ((apduBuffer[5] << 8 ) & (short)0x0000FF00));
// tests if the debit is valid
if((balance >= amount) && (amount > 0))
// does the debit operation
balance -= amount ;
// writes the new balance into the APDU buffer
// (writes after the debit amount in the APDU buffer)
apduBuffer[7] = (byte)(balance >> 8) ;
apduBuffer[8] = (byte)balance ;
// sends the APDU response
apdu.setOutgoing() ; // Switches to output mode
apdu.setOutgoingLength((short)2) ; // 2 bytes to return
// offset and length of bytes to return in the APDU buffer
apdu.sendBytes((short)7, (short)2) ;
/*short points = 10;
AID loyaltyID = JCSystem.lookupAID(loyaltyAID, (short)0, (byte)loyaltyAID.length);
if(loyaltyID == null)
ISOException.throwIt((short)(SW_LOYALTY_APP_NOT_EXIST));
TestInterface sio = (TestInterface)(JCSystem.getAppletShareableInterfaceObject(loyaltyID, (byte)0x00));
if(sio == null)
ISOException.throwIt((short)(SW_FAILED_TO_OBTAIN_SIO));
sio.creditPoints(points);*/
else
// throw a UserException with illegal amount as reason
throw new UserException(ILLEGAL_AMOUNT) ;
/* byte points = (byte)0x0A;
//short points = 10;
AID loyaltyID = JCSystem.lookupAID(loyaltyAID, (short)0, (byte)loyaltyAID.length);
if(loyaltyID == null)
ISOException.throwIt((short)(SW_LOYALTY_APP_NOT_EXIST));
TestInterface sio = (TestInterface)JCSystem.getAppletShareableInterfaceObject(loyaltyID, (byte)0x00);
if(sio == null)
ISOException.throwIt((short)(SW_FAILED_TO_OBTAIN_SIO));
sio.creditPoints(points);*/
* Performs the "credit" operation on this counter. The operation is allowed only
* if master pin is validated
* @param apdu The APDU to process.
* @exception ISOException If the APDU is invalid or if the amount to credit
* is invalid.
private void credit(APDU apdu) throws ISOException
// check valid Applet state
if(OPSystem.getCardContentState() == OPSystem.APPLET_BLOCKED)
ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
// the operation is allowed only if master pin is validated and authentication is done
if (!validPIN || !authenticationDone)
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
// get the APDU buffer
byte[] apduBuffer = apdu.getBuffer();
// gets the length of bytes to recieved from the terminal and receives them
// if does not receive 2 bytes throws an ISO.SW_WRONG_LENGTH exception
if(apduBuffer[4] != 2 || apdu.setIncomingAndReceive() != 2)
throw new ISOException(ISO7816.SW_WRONG_LENGTH) ;
// reads the credit amount from the APDU buffer
// starts at offset 5 in the APDU buffer since the 5 first bytes
// are used by the APDU command part
short amount = (short)(((apduBuffer[6]) & (short)0x000000FF)
| ((apduBuffer[5] << 8) & (short)0x0000FF00));
// tests if the credit is valid
if(((short)(balance + amount) > maximumBalance) || (amount <= (short)0))
throw new ISOException(ISO7816.SW_DATA_INVALID) ;
else
// does the credit operation
balance += amount ;
* Performs the "init_update" security operation.
* @param apdu The APDU to process.
private void init_update( APDU apdu )
// receives data
apdu.setIncomingAndReceive();
// checks for existing active secure channel
if(channelOpened)
// close the openned security channel
try
securityObject.closeSecureChannel(secureChannel);
catch(CardRuntimeException cre2)
// channel number is invalid. this case is ignored
// set the channel flag to close
channelOpened = false;
try
// open a new security channel
secureChannel = securityObject.openSecureChannel(apdu);
// set the channel flag to open
channelOpened = true;
// get expected length
short expected = apdu.setOutgoing();
// send authentication result
// expected length forced to 0x1C
apdu.setOutgoingLength((byte)0x1C);
apdu.sendBytes(ISO7816.OFFSET_CDATA, (byte)0x1c);
catch(CardRuntimeException cre)
// no available channel or APDU is invalid
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
* Performs the "external_authenticate" security operation.
* @param apdu The APDU to process.
private void external_authenticate( APDU apdu )
// receives data
apdu.setIncomingAndReceive();
// checks for existing active secure channel
if(channelOpened)
try
// try to authenticate the client
securityObject.verifyExternalAuthenticate(secureChannel, apdu);
// authentication succeed
authenticationDone = true;
catch(CardRuntimeException cre)
// authentication fails
// set authentication flag to fails
authenticationDone = false;
// close the openned security channel
try {
securityObject.closeSecureChannel(secureChannel);
} catch(CardRuntimeException cre2) {
// channel number is invalid. this case is ignored
// set the channel flag to close
channelOpened = false;
// send authentication result
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
// send authentication result
ISOException.throwIt(ISO7816.SW_NO_ERROR);
else
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
* The "reset_security" method close an opened secure channel if exist.
* @return void.
public void reset_security()
// close the secure channel if openned.
if(secureChannel != (byte)0xFF)
try
// close the openned security channel
securityObject.closeSecureChannel(secureChannel);
catch(CardRuntimeException cre2)
// channel number is invalid. this case is ignored
// reset security parameters
secureChannel = (byte)0xFF;
channelOpened = false;
authenticationDone = false;
return;
and the 3rd code is:
package com.gemplus.examples.loyalty;
import javacard.framework.Shareable;
public interface TestInterface extends Shareable
// public void creditPoints(byte points) ;
public void creditPoints(byte points) ;
Thanks in advance......Thanks. I know they are not the same thing. A package cannot be deleted if it contains one or more applets.
I tried to delete by typing in the applet AID first, but it just doesn't work. And of course it doesn't work for package AID.
Both the package and applet AID are generated in JBuilder, which looks like this, package AID(6D 79 70 61 63 6B 61 67 31),
applet AID(6D 79 70 61 63 30 30 30 31),
instance AID(6D 79 70 61 63 30 30 30 31)
I've tried those three AIDs, it's not working.
Thanks. -
Applet load times got you down?
Then vote for this RFE:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6346341
The whole discussion started here:
http://forum.java.sun.com/thread.jspa?threadID=678853&tstart=0
-DennisI have the same problem, and add this replay to motivate a clever person to solve this problem.
My situation is:
20 Applets (or so) on one page - they span exactly on Thread - if clicked. And if I reload the page they never work again - I have to restart the browser.
If I browse to the page with the applets I have complete browser crash in 3 of 4 cases. But the first time I visted the page after reboot of Linux (everything less don't help) all the applets work.
If I put only one Applet on a page and reload this page, then in a few lucky cases the Applet works a second time.
On windows everything is fine, so I don't think my
Applets are the problem.
On linux I tried several version of upto Mozilla 0.9.8
everytime the same (but 0.9.8 don't work at all with the plugin). -
ECATT abends during recording when lead selection is set to 0 on web dynpro
We have a web dynpro application that works ok when running by itself. When we tried to record ECATT testing on it, it abended after we click on a selection from a list of values. The error on the browser indicated an error on the "lead select". After reviewing the dump, we found that it abends on an exception when the lead selection on the ALV is not set. When we changed our code to set the lead selection to 1, the ECATT recording worked.
We have a requirement to set the lead selection of ALV to 0 so we need to change back our code. We just did the setting to 1 just to get ECATT recording to work for now. Does anybody know why ECATT requires this? Is there a support packs that fixes this?
Here is a snippet from ST22 for more details on this:
Runtime Errors UNCAUGHT_EXCEPTION
Exception CX_WD_CONTEXT
Date and Time 2007/02/07 14:50:06
Short text
An exception occurred that was not caught.
What happened?
The exception 'CX_WD_CONTEXT' was raised, but it was not caught anywhere along
the call hierarchy.
Since exceptions represent error situations and this error was not
adequately responded to, the running ABAP program
'CL_WDR_CONTEXT_NODE===========CP' has to be
terminated.
What can you do?
Note down which actions and inputs caused the error.
To process the problem further, contact you SAP system
administrator.
Using Transaction ST22 for ABAP Dump Analysis, you can look
at and manage termination messages, and you can also
keep them for a long time.
Error analysis
An exception occurred which is explained in detail below.
The exception, which is assigned to class 'CX_WD_CONTEXT', was not caught and
therefore caused a runtime error.
The reason for the exception is:
The lead selection has not been set. VIEW_TABLE
How to correct the error
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"UNCAUGHT_EXCEPTION" "CX_WD_CONTEXT"
"CL_WDR_CONTEXT_NODE===========CP" or "CL_WDR_CONTEXT_NODE===========CM00V"
"_RAISE_ELEMENT_NOT_FOUND"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
System environment
SAP-Release 700
Application server... "torsapd01"
Network address...... "10.2.75.183"
Operating system..... "Windows NT"
Release.............. "5.2"
Hardware type........ "4x AMD64 Level"
Character length.... 8 Bits
Pointer length....... 64 Bits
Work process number.. 0
Shortdump setting.... "full"
Database server... "TORSAPD01"
Database type..... "MSSQL"
Database name..... "PR3"
Database user ID.. "dbo"
Char.set.... "English_United State"
SAP kernel....... 700
created (date)... "Aug 28 2006 22:20:27"
create on........ "NT 5.2 3790 Service Pack 1 x86 MS VC++ 14.00"
Database version. "SQL_Server_8.00 "
Patch level. 75
Patch text.. " "
Database............. "MSSQL 7.00.699 or higher, MSSQL 8.00.194"
SAP database version. 700
Operating system..... "Windows NT 5.0, Windows NT 5.1, Windows NT 5.2"
Memory consumption
Roll.... 16128
EM...... 16759616
Heap.... 0
Page.... 0
MM Used. 12713776
MM Free. 4042608
User and Transaction
Client.............. 200
User................ "SIC0010"
Language Key........ "E"
Transaction......... " "
Program............. "CL_WDR_CONTEXT_NODE===========CP"
Screen.............. "SAPMHTTP 0010"
Screen Line......... 2
Information on Caller ofr "HTTP" Connection:
Plug-in Type.......... "HTTP"
Caller IP............. "10.49.77.47"
Caller Port........... 8000
Universal Resource Id. "/sap/bc/webdynpro/sap/zpr3_base_price/"
Information on where terminated
Termination occurred in the ABAP program "CL_WDR_CONTEXT_NODE===========CP" -
in "_RAISE_ELEMENT_NOT_FOUND".
The main program was "SAPMHTTP ".
In the source code you have the termination point in line 11
of the (Include) program "CL_WDR_CONTEXT_NODE===========CM00V".
Source Code Extract
Line
SourceCde
1
method RAISEELEMENT_NOT_FOUND.
2
data: l_count type I,
3
l_node_name type string.
4
5
l_node_name = if_wd_context_node~get_path( ).
6
7
l_count = if_wd_context_node~get_element_count( ).
8
if l_count = 0.
9
raise exception type cx_wd_context exporting textid = cx_wd_context=>NODE_EMPTY node_nam
10
elseif element_index = if_wd_context_node=>use_lead_selection.
>>>>>
raise exception type cx_wd_context exporting textid = cx_wd_context=>NO_LEAD_SELECTION n
12
else.
13
raise exception type cx_wd_context exporting textid = cx_wd_context=>ELEMENT_NOT_FOUND n
14
endif.
15
endmethod.
Contents of system fields
Name
Val.
SY-SUBRC
0
SY-INDEX
1
SY-TABIX
0
SY-DBCNT
2
SY-FDPOS
0
SY-LSIND
0
SY-PAGNO
0
SY-LINNO
1
SY-COLNO
1
SY-PFKEY
SY-UCOMM
SY-TITLE
HTTP Control
SY-MSGTY
E
SY-MSGID
TD
SY-MSGNO
600
SY-MSGV1
000003587101
SY-MSGV2
0001
SY-MSGV3
EN
SY-MSGV4
SY-MODNO
0
SY-DATUM
20070207
SY-UZEIT
145005
SY-XPROG
SAPCNVE
SY-XFORM
CONVERSION_EXITHi Eugene,
i suggest you raise an SMP ticket for these.
Looks like a bug at first glance.
regards
Phil -
JRE freeze when loading applet twice, through VSAT network
Here is a good one for you guys I think ...
===========
What I got:
===========
I have a java web application, runing with Tomcat 5.5.
I use a Apache HTTP Server 2.0.52 for my statiques ressources (html, etc ...), and the modjk connector 1.2.13 to forward all the dynamic requests from the client to the application server.
One of my html pages contains a signed java applet.
Basically, this applet control a scanner and send the scanned image to the web application server.
This applet:
- use some swing components
- use the netscape.javascript.JSObject to call javascript functions
- use the morena API (which include a native library) in order to control a TWAIN scanner
- format the scanned image into a JPEG image
- send the formatted image to the web server, using an HttpURLConnection
(I use a servlet on server side to get the uploaded image)
- wait for the server response, that tells my applet if the upload has been successfull or not
Some additional infos:
- I use morena 6.2.0.0
- I use JRE 1.5.0.0.1 to run the applet
- JRE on client side is configured as follow:
- no applet caching
- network parameters: "use the browser parameters"
==============
My problem is:
==============
- Through a LAN network, the applet works perfectly ...
- Through an internet network (I use a VSAT / IDIRECT network), I can load and run my applet the first time
but when I try to run my applet for the second time (without closing the browser), it just doesn't start, and the JRE crash
(i.e. the java console freeze ..., just like if it was waiting for something ...)
nothing happen after that, and I have to kill my JRE / Browser
the funny stuff about it is that the applet works fine (even through VSAT network) when I don't upload the scanned image on the server
load and run ok as many time as I want ...
=> seems that something's going wrong during the uploading process
==========================
What I have already tried:
==========================
1/ getting rid of the Java - Javascript communication (JSObject seems to have heaps of bugs ...)
=> no changes
2/ be careful to close correctly my HttpURLConnection, with a HttpURLConnection.disconnect()
=> no changes
3/ put the morena jars directly on the client side (in the lib/ext directory of the JRE):
the morena API use a native library, and apparently, a native library can not be loaded by 2 different ClassLoader
just to avoid any "java.lang.UnsatisfiedLinkError"
as shown on http://forum.java.sun.com/thread.jspa?forumID=31&threadID=628889
=> no changes
4/ have a closer look on the http apache server, just to get rid of the error
"OS 64)The specified network name is no longer available. : winnt_accept: Asynchronous AcceptEx failed."
as shown on the bug 21425 in http://issues.apache.org/bugzilla/show_bug.cgi?id=21425
=> no changes
5/ use the upgrade version 1.5.0.6 of the JRE
=> no changes
==========
ANY HELP ?
==========
and as usual, I had to fix this problem for yesterday ... :)))
Any ideas about that ?
need more infos ?: just let me know
======================================================================================
Here is the piece of code I use to upload the image from the client to the web server:
======================================================================================
* Upload de cette image sur le serveur, apr�s passage au format JPEG
* @param imageSelectionnee BufferedImage image � transf�rer
* @throws ComposantNumerisationException exception pouvant etre lev� lors de l'upload
public void uploadImage(BufferedImage imageSelectionnee)
throws ComposantNumerisationException {
// connexion http au server
HttpURLConnection connexionServer = null;
// flux de sortie, permettant d'envoyer les donn�es vers le serveur
OutputStream fluxSortie = null;
// parametres pour le libelle de l'exception
ParametresProprietes parametres = null;
// flux d'entr�e, pour lire la r�ponse du serveur
BufferedReader fluxEntree = null;
// r�ponse du serveur
String reponseServeur = null;
// image au format JPEG
BufferedImage imageFormatJPEG = null;
try {
/* conversion de l'image au format JPEG */
imageFormatJPEG = this.formatterImage(imageSelectionnee);
/* ouverture d'une connexion vers le serveur */
connexionServer = this.ouvrirConnexion(imageFormatJPEG);
/* ecriture des donn�es dans le flux de sortie, vers le serveur */
// cr�ation d'un outputStream
fluxSortie = connexionServer.getOutputStream();
// transfert des donn�es vers le serveur
ImageIO.write(imageFormatJPEG, Constantes.TYPE_IMAGE, fluxSortie);
fluxSortie.flush();
/* lecture de la r�ponse du serveur */
// cr�ation d'un flux de lecture sur le flux d'entr�e
fluxEntree = new BufferedReader(new InputStreamReader(
connexionServer.getInputStream()));
// lecture de la r�ponse du serveur
reponseServeur = fluxEntree.readLine();
// v�rification du succes de l'upload, en fonction de la r�ponse du serveur
if (!reponseServeur.startsWith("REPONSE")) {
/* cas ou le message retour ne commence pas par "REPONSE":
* ce n'est pas la r�ponse de la servlet
* => Tomcat nous a redirig� vers la page d'authentification */
fenetreNumerisation.redirigerFenetreAuthentification();
} else if (reponseServeur.compareTo("REPONSE:OK") != 0) {
// la r�ponse du serveur indique qu'il y a eu un probl�me lors de l'upload
throw new IOException(reponseServeur);
} catch (IOException e) {
// cr�ation des parametres pour ce libelle d'erreurs
parametres = new ParametresProprietes();
parametres.ajouterParametre("0", e.toString());
throw new ComposantNumerisationException(
proprietes.getPropriete("ERREUR_UPLOAD", null),
proprietes.getPropriete("ERREUR_UPLOAD_TECH", parametres),
ComposantNumerisationException.ERREUR_NON_BLOCANTE);
} finally {
try {
// fermeture de ce flux de sortie
if (null != fluxSortie) {
fluxSortie.close();
// fermeture du flux de lecture de la reponse
if (null != fluxEntree) {
fluxEntree.close();
} catch (IOException e) {
// fermeture de la connexion
if (null != connexionServer) {
connexionServer.disconnect();
* Ouverture d'une connexion vers la servlet d'upload de l'image
* @param image BufferedImage image � transf�rer
* @return HttpURLConnection une connexion http
* @throws IOException exception IO
* @throws ComposantNumerisationException exception
private HttpURLConnection ouvrirConnexion(BufferedImage image)
throws IOException, ComposantNumerisationException {
// url du server
URL urlServer = null;
// connexion http au server
HttpURLConnection connexionServer = null;
// signature
String signature = null;
// g�n�ration de la signature de l'image � transf�rer
signature = this.genererSignatureImage(image);
// construction de l'url du serveur � appeler pour cet upload
// en incluant un parametre pour transmettre la signature de l'image � transf�rer
// + identifiant du passeport d'urgence courant
urlServer = new URL(this.urlServeur + this.action +
"?" + Constantes.PARAM_SIGNATURE_IMAGE + "=" + signature +
"&" + Constantes.PARAM_IDDEMANDE + "=" + idDemande +
"&" + Constantes.PARAM_CODEMAJ + "=" + codeMaj +
"&" + Constantes.PARAM_TYPEDEMANDE + "=" + typeDemande);
if (null == urlServer) {
throw new IOException(proprietes.getPropriete(
"ERREUR_UPLOAD_CREATION_URL_SERVEUR", null));
// ouverture d'une connexion http, gr�ce a cette url du server
connexionServer = (HttpURLConnection) urlServer.openConnection();
if (null == connexionServer) {
throw new IOException(proprietes.getPropriete(
"ERREUR_UPLOAD_OUVERTURE_CONNEXION_SERVEUR", null));
// param�trage de cette connexion
// m�thode de transmission = POST
connexionServer.setRequestMethod("POST");
// autorisation de lire les donn�es venant du serveur
connexionServer.setDoInput(true);
// autorisation d'�crire des donn�es vers le serveur
connexionServer.setDoOutput(true);
// pas d'utilisation de caches
connexionServer.setUseCaches(false);
connexionServer.setDefaultUseCaches(false);
// sp�cification du type des donn�es que l'on envoie vers le serveur
connexionServer.setRequestProperty("content-type", "img/jpeg");
return connexionServer;
}=======================================================================================
Here is the piece of code I use on server side to get the scaned image from the client:
=======================================================================================
* Lecture des donn�es en provenance de l'applet
* @param request HttpServletRequest
* @return ByteArrayOutputStream buffer contenant les donn�es lues
* @throws TechnicalException exception
* @throws FunctionalException si erreur fonctionnelle
private ByteArrayOutputStream lireDonnees(HttpServletRequest request)
throws FunctionalException, TechnicalException {
// stream de sortie sur l'image
ByteArrayOutputStream baos = null;
// id du passeport d'urgence au format Integer
// image issue de l'applet
BufferedImage image = null;
try {
/* r�cup�ration de l'image */
image = ImageIO.read(request.getInputStream());
if (null == image) {
logger.error(THIS_CLASS + Libelles.getLibelle("ERR-TEC-16", null));
throw new TechnicalException(new ErreurVO("ERR-TEC-16",
null, "", true, false, false));
} catch (IllegalArgumentException e) {
logger.error(THIS_CLASS + Libelles.getLibelle("ERR-TEC-13", null));
throw new TechnicalException(new ErreurVO("ERR-TEC-13",
null, "", true, false, false));
} catch (IOException e) {
logger.error(THIS_CLASS + Libelles.getLibelle("ERR-TEC-16", null));
throw new TechnicalException(new ErreurVO("ERR-TEC-16",
null, "", true, false, false));
return baos;
* Ecriture de la reponse � envoyer � l'applet
* @param response HttpServletResponse
* @param erreur Message d'erreur
* @throws IOException exception
private void ecrireReponse(HttpServletResponse response, String erreur) throws IOException {
// r�ponse � envoyer � l'applet
String reponseServer = null;
// flux de reponse
PrintWriter fluxReponse = null;
response.setContentType("text/html");
// construction de la r�ponse � envoyer � l'applet
if (null == erreur) {
reponseServer = "REPONSE:OK";
} else {
/* cas ou il y a eu une exception lev�e lors de la reception des donn�es */
reponseServer = "REPONSE:ERREUR:" + erreur;
if (logger.isDebugEnabled()) {
logger.debug(THIS_CLASS +
"Envoie de la r�ponse � l'applet, indiquant si l'upload s'est bien d�roul�: " +
reponseServer);
//envoie de la r�ponse a l'applet
fluxReponse = response.getWriter();
fluxReponse.println(reponseServer);
fluxReponse.close();
}==============================================================================
here is the traces I get when the applet doesn't work, through a VSAT network:
==============================================================================
Java Plug-in 1.5.0_01
Utilisation de la version JRE 1.5.0_01 Java HotSpot(TM) Client VM
R�pertoire d'accueil de l'utilisateur = C:\Documents and Settings\assistw
network: Chargement de la configuration du proxy d�finie par l'utilisateur ...
network: Termin�.
network: Chargement de la configuration du proxy � partir de Netscape Navigator ...
network: Erreur lors de la lecture du fichier de registre : C:\Documents and Settings\assistw\Application Data\Mozilla\registry.dat
network: Termin�.
network: Chargement de la configuration proxy du navigateur ...
network: Termin�.
network: Configuration du proxy : Configuration du proxy du navigateur
basic: Le cache est d�sactiv� par l'utilisateur
c: effacer la fen�tre de la console
f: finaliser les objets de la file d'attente de finalisation
g: lib�rer la m�moire
h: afficher ce message d'aide
l: vider la liste des chargeurs de classes
m: imprimer le relev� d'utilisation de la m�moire
o: d�clencher la consignation
p: recharger la configuration du proxy
q: masquer la console
r: recharger la configuration des politiques
s: vider les propri�t�s syst�me et d�ploiement
t: vider la liste des threads
v: vider la pile des threads
x: effacer le cache de chargeurs de classes
0-5: fixer le niveau de tra�age � <n>
basic: R�cepteur de modalit�s enregistr�
basic: R�f�rence au chargeur de classes : sun.plugin.ClassLoaderInfo@b30913, refcount=1
basic: R�cepteur de progression ajout� : sun.plugin.util.GrayBoxPainter@77eaf8
basic: Chargement de l'applet...
basic: Initialisation de l'applet...
basic: D�marrage de l'applet...
network: Connexion de http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
security: Acc�s aux cl�s et au certificat dans le profil utilisateur Mozilla : null
security: Chargement des certificats AC racine depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
security: Certificats AC racine charg�s depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\cacerts
security: Chargement des certificats JPI depuis C:\Documents and Settings\assistw\Application Data\Sun\Java\Deployment\security\trusted.certs
security: Certificats JPI charg�s depuis C:\Documents and Settings\assistw\Application Data\Sun\Java\Deployment\security\trusted.certs
security: Chargement des certificats JPI depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\trusted.certs
security: Certificats JPI charg�s depuis C:\PROGRA~1\Java\JRE15~1.0_0\lib\security\trusted.certs
security: Chargement des certificats depuis la zone de stockage des certificats de session JPI
security: Certificats charg�s depuis la zone de stockage des certificats de session JPI
security: Recherche du certificat dans le magasin de certificats permanent JPI
security: Recherche du certificat dans la zone de stockage des certificats de session JPI
security: Obtenir l'objet de stockage des cl�s de la zone de stockage des certificats AC racine
security: Obtenir l'objet de stockage des cl�s de la zone de stockage des certificats AC racine
security: Recherche du certificat dans la zone de stockage des certificats AC racine
security: D�terminer si le certificat peut �tre v�rifi� � l'aide des certificats de la zone de stockage des certificats AC racine
... [check certifications]
sun.misc.Launcher$ExtClassLoader@92e78c
<no principals>
java.security.Permissions@157b46f (
(java.lang.RuntimePermission stopThread)
(java.security.AllPermission <all permissions> <all actions>)
(java.io.FilePermission \C:\Program Files\Java\jre1.5.0_01\lib\ext\sunjce_provider.jar read)
(java.util.PropertyPermission java.version read)
(java.util.PropertyPermission java.vm.name read)
(java.util.PropertyPermission java.vm.vendor read)
(java.util.PropertyPermission os.name read)
(java.util.PropertyPermission java.vendor.url read)
(java.util.PropertyPermission java.vm.specification.vendor read)
(java.util.PropertyPermission java.specification.vendor read)
(java.util.PropertyPermission os.version read)
(java.util.PropertyPermission java.specification.name read)
(java.util.PropertyPermission java.class.version read)
(java.util.PropertyPermission file.separator read)
(java.util.PropertyPermission java.vm.version read)
(java.util.PropertyPermission os.arch read)
(java.util.PropertyPermission java.vm.specification.name read)
(java.util.PropertyPermission java.vm.specification.version read)
(java.util.PropertyPermission java.specification.version read)
(java.util.PropertyPermission java.vendor read)
(java.util.PropertyPermission path.separator read)
(java.util.PropertyPermission line.separator read)
(java.net.SocketPermission localhost:1024- listen,resolve)
... [check certifications]
security: La v�rification du certificat � l'aide des certificats AC racine a �chou�
security: Aucune information d'horodatage disponible
basic: Modalit� empil�e
basic: Modalit� d�sempil�e
basic: Utilisateur s�lectionn� : 0
security: L'utilisateur a accord� les droits d'acc�s au code pour cette session seulement
security: Ajout du certificat dans la zone de stockage des certificats de session JPI
security: Certificat ajout� dans la zone de stockage des certificats de session JPI
security: Enregistrement des certificats dans la zone de stockage des certificats de session JPI
security: Certificats enregistr�s dans la zone de stockage des certificats de session JPI
... [check certifications]
sun.plugin.security.PluginClassLoader@10fe2b9
<no principals>
java.security.Permissions@fe315d (
(java.lang.RuntimePermission accessClassInPackage.sun.audio)
(java.lang.RuntimePermission stopThread)
(java.security.AllPermission <all permissions> <all actions>)
(java.util.PropertyPermission java.version read)
(java.util.PropertyPermission java.vm.name read)
(java.util.PropertyPermission javaplugin.version read)
(java.util.PropertyPermission java.vm.vendor read)
(java.util.PropertyPermission os.name read)
(java.util.PropertyPermission java.vendor.url read)
(java.util.PropertyPermission java.vm.specification.vendor read)
(java.util.PropertyPermission java.specification.vendor read)
(java.util.PropertyPermission os.version read)
(java.util.PropertyPermission browser.vendor read)
(java.util.PropertyPermission java.specification.name read)
(java.util.PropertyPermission java.class.version read)
(java.util.PropertyPermission file.separator read)
(java.util.PropertyPermission browser.version read)
(java.util.PropertyPermission java.vm.version read)
(java.util.PropertyPermission os.arch read)
(java.util.PropertyPermission browser read)
(java.util.PropertyPermission java.vm.specification.name read)
(java.util.PropertyPermission java.vm.specification.version read)
(java.util.PropertyPermission java.specification.version read)
(java.util.PropertyPermission java.vendor read)
(java.util.PropertyPermission path.separator read)
(java.util.PropertyPermission http.agent read)
(java.util.PropertyPermission line.separator read)
(java.net.SocketPermission rma_phileas connect,accept,resolve)
(java.net.SocketPermission localhost:1024- listen,resolve)
... [check certifications]
sun.misc.Launcher$ExtClassLoader@92e78c
<no principals>
java.security.Permissions@bd09e8 (
(java.lang.RuntimePermission stopThread)
(java.security.AllPermission <all permissions> <all actions>)
(java.io.FilePermission \C:\Program Files\Java\jre1.5.0_01\lib\ext\Smorena.jar read)
(java.util.PropertyPermission java.version read)
(java.util.PropertyPermission java.vm.name read)
(java.util.PropertyPermission java.vm.vendor read)
(java.util.PropertyPermission os.name read)
(java.util.PropertyPermission java.vendor.url read)
(java.util.PropertyPermission java.vm.specification.vendor read)
(java.util.PropertyPermission java.specification.vendor read)
(java.util.PropertyPermission os.version read)
(java.util.PropertyPermission java.specification.name read)
(java.util.PropertyPermission java.class.version read)
(java.util.PropertyPermission file.separator read)
(java.util.PropertyPermission java.vm.version read)
(java.util.PropertyPermission os.arch read)
(java.util.PropertyPermission java.vm.specification.name read)
(java.util.PropertyPermission java.vm.specification.version read)
(java.util.PropertyPermission java.specification.version read)
(java.util.PropertyPermission java.vendor read)
(java.util.PropertyPermission path.separator read)
(java.util.PropertyPermission line.separator read)
(java.net.SocketPermission localhost:1024- listen,resolve)
scl:
Morena - Image Acquisition Framework version 6.2.0.0.
Copyright (c) Gnome s.r.o. 1999-2004. All rights reserved.
Licensed to "XXX".
network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageInputStreamSpi avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageInputStreamSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageOutputStreamSpi avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageOutputStreamSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageTranscoderSpi avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageTranscoderSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageReaderSpi avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageReaderSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
network: Connexion de http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageWriterSpi avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/META-INF/services/javax.imageio.spi.ImageWriterSpi avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
network: Connexion de http://rma_phileas/Client/flux/protected/uploadimage.do?signature=c07690c12904320a253cbdeeded59238&idDemande=7&codeMaj=1133967329473&typeDemande=PU avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/flux/protected/uploadimage.do?signature=c07690c12904320a253cbdeeded59238&idDemande=7&codeMaj=1133967329473&typeDemande=PU avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"
basic: Arr�t de l'applet...
basic: R�cepteur de progression supprim� : sun.plugin.util.GrayBoxPainter@77eaf8
basic: Jonction du thread d'applet...
basic: Destruction de l'applet...
basic: Elimination de l'applet...
basic: Sortie de l'applet...
basic: Thread d'applet joint...
basic: R�cepteur de modalit�s non enregistr�
basic: Recherche d'informations...
basic: Lib�ration du chargeur de classes : sun.plugin.ClassLoaderInfo@b30913, refcount=0
basic: Mise en cache du chargeur de classes : sun.plugin.ClassLoaderInfo@b30913
basic: Taille de cache du chargeur de classes courant : 1
basic: Termin�...
basic: R�cepteur de modalit�s enregistr�
basic: R�f�rence au chargeur de classes : sun.plugin.ClassLoaderInfo@b30913, refcount=1
basic: R�cepteur de progression ajout� : sun.plugin.util.GrayBoxPainter@1e16483
basic: Chargement de l'applet...
basic: Initialisation de l'applet...
basic: D�marrage de l'applet...
network: Connexion de http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec proxy=DIRECT
network: Connexion http://rma_phileas/Client/html/composants/scanner/SAppletNumerisation.jar avec cookie ":::langueSettings:::=FR; :::menuSettings_gabaritMaquette:::=%3CSETTINGS%3E%3CVERSION%3EVersion%201.2-Utilisateur%3C/VERSION%3E%3CINDEX_ITEM1%3E0%3C/INDEX_ITEM1%3E%3CINDEX_ITEM2%3E0%3C/INDEX_ITEM2%3E%3CINDEX_ITEM3%3Enull%3C/INDEX_ITEM3%3E%3C/SETTINGS%3E; JSESSIONID=D064486FD6C7CC17E7B256B66965FFEE"A workaround would be: don't use IE9. You want a solution, not a workaround.
I think at this juncture you are best of creating a new bug report and be sure to reference the old closed one. It doesn't look entirely related though, your symptoms are different from what is described in it (freeze VS a crash). You tried this on several systems right? Also on machines on a different network?
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7072601 -
Problems with pacman applet, and advice on a gaming portfolio
Hi
I recently made a pacman applet, im having a few problems with it though, the first time the applet is run on a browser, the ghosts(represented by squares) often dont appear or if they do, they are stuck in walls, this never happens when i run offline on my computer. Is this because the very first time the applet is run, it doesnt load properly, but the second time some of the files are in the cache so it loads fully?
Also everytime i refresh the browser the applet dissapears and is replaced with a blank space and a cross in the top left hand corner, does anyone know the reason for this?
The applet can be found below, if you do decide to play it, please bear in mind what i have said, so it might not load correctly the first time, if this is the case please refresh, or close the broswer and reopen the link! Also you will need to click the applet for it to gain focus before you can move pacman - use the arrow keys the control pacman.
http://www.renaissance-designs.co.uk/Satwant/java/pacman/
Id also be very gratful for some advice - id like a change in career, ive always wanted to get into gaming, ive had some previous knowledge in java i made a programme that could generate its own poetry in java for my dissatation, but i still never had a huge amount of confidence, and so went into websites.
BUT now i have decided to take the leap back into programming and give it a go, which is why ive made this game.
I thought id make a portfolio and try and apply for a few gaming jobs. This applet took me two weeks to make and it was in my spare time, i am fully aware its not perfect, and it doesnt look great, but i would like to know what people think of it, also how many more games do you think i should make, before i apply for gaming jobs? Does anyone have any advice on what would make a good portfolio for a java gaming job?
Thanks alot, i look forward to what you think of the game, and your advice!
SSKenthsskenth wrote:
Thanks for getting back to me with that information, i didnt know you could see that information with just a simple right click!
But im afraid that doesnt really help me solve the problem, im not sure what all of that information means! :SI have very little experience with applets, but I can tell you what I would do to debug this (forgive me if you already know this stuff).
Look at the stack trace you get in the Java Console that I posted earlier. Each line contains a method that was called from the method on the previous line. So, java.lang.Thread.run() called sun.applet.AppletPanel.run(), which called Room.init(), etc. Look at the topmost line whose method is something you wrote, not something in the standard Java libraries. In your case it looks like PaintSurface.java (specifically, line 22). Look at what line 22 of PaintSurface.java is doing, it's calling Thread.start(). If you check out the Javadoc for Thread.start(), it says IllegalThreadStateException gets thrown if you call start() on a thread that has already started. So that's your problem. Without looking at your code, I'd assume you want to stop your thread in your applet's destroy() override, and instead of reusing it, create a new one each time init() is called.
Ill try and look into, thanks again though, it gives me somthing to work with :D
Btw when you first ran the applet, did all the ghosts(3) load up correctly?Unfortunately, no. The first time I ran it, there was only 1 ghost (or maybe all 3 overlapping each other?) at the top of the screen, and they never moved. Refreshing once made the game play as I think you want it to. Refreshing a third time gave the dreaded red X.
...oh and just out of curiosity,,, did u have fun playing the game :DSure did.
Maybe you are looking for
-
Batch Procedure Not Working For Image Resizing in Fireworks 8
Scaling graphics with a batch process. You can alter the height and width of images being exported using the Scale option in the Batch Process dialog box. To set scaling options for batch-processed files: Select Scale from the Batch Options list and
-
I have a mac on my desk (iMac) as well as a MBP that I carry with me. Is there any software application I can install to allow me to stream, either on the same network or over the internet, my iSight video from one computer to another?
-
Why Can't I Make Changes To This Image ?
I have a black & white image, edited some time ago in a trial version of LightZone software,taken into PSE3, and saved as a flattened RGB .tif file. For some reason I can't apply any filters/effects/layer styles to this image. The filters/effects etc
-
does anybody has a complete demo show cdc with oracle to oracle ? and Increase refresh. thanks.
-
PREP_IMPORT/RUN_RSPTBFIL_PREP Error
Hi We are doing upgrade of SAP R/3 4.7 Ext 2.00 to SAP ECC 6.0 Include EHP4 SR1. Encounter with the Follwoing error at PREP_IMPORT/RUN_RSPTBFIL_PREP Phase. Please advise. Log: 1 ETQ201 Entering upgrade-phase "RUN_RSPTBFIL_PREP" ("20090923223640") 2