Appletviewer problem...
I've literally changed a few Button on my applet to JButton and when I compile it one of the button fills the entire appletviewer. I've tried changing it back to Button but this still happens.
Any ideas? :S
import java.awt.*; //Import all the classes within the abstract windows toolkit
import java.applet.*; //Import applet class
import java.awt.event.*;
import java.awt.Graphics.*;
import javax.swing.*;
public class Cinema extends JApplet implements ActionListener
JButton seating, exit1, exit2, calcost, sexit; //Declare buttons
JButton a1, a2, a3, a4, a5, a6, a7, a8;
JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12;
JButton c1, c2, c3, c4, c5, c6, c7, c8;
JButton empty, empty1, empty2, empty3, empty4, empty5;
Button next, exit;
Font verdana; //Declare font
Label title, description, movieselect, aco, stitle, moviec; //Declare labels
Frame mSelect, seatdisplay; //Declare frames
Panel panelLeft, panelMiddle, panelRight, panelBottom, panelTop, panelW; //Declare panels
TextField chooseTime, chooseAge, movieInfo; //Declare text fields
// private int t; //Declare integer variable
private Choice movies; //Declare combo box
private char ageGroup; //Declare character variable
private int filmTime;
private double chSeat;
public void init()
setSize(500,100); //Set size of applet
setBackground(Color.green); //Set colour of applet to green
verdana = new Font("Verdana", Font.BOLD,18); //Define font parameters
title = new Label("Welcome to Jay's Cinema Booking System"); //Define label
title.setForeground(Color.black); //Make label black
title.setFont(verdana); //Set label to the Verdana font
description = new Label("Choose a film, time and seat #.");
description.setForeground(Color.black);
add(title); //Add title label to applet
add(description);
movieselect = new Label("Select movie:");
movieselect.setForeground(Color.black);
movies = new Choice(); //Define new combo box
movies.setFont(new Font("Verdana", Font.BOLD,12));
movies.add("Saw IV"); //Add item to combo box
movies.add("Good Luck Chuck");
movies.add("Silk");
movies.add("Planet Terror");
movies.setForeground(Color.white); //Set foreground of combo box to white
movies.setBackground(Color.black); //Set background of combo box to black
next = new Button("Continue"); //Define new button
next.setForeground(Color.white);
next.setBackground(Color.black);
next.addActionListener(this); //Have actions listen to this button
add(next); //Add button to the applet
exit = new Button("Exit");
exit.setForeground(Color.white);
exit.setBackground(Color.black);
exit.addActionListener(this);
add(exit);
seating = new JButton("Continue");
seating.setForeground(Color.white);
seating.setBackground(Color.black);
seating.addActionListener(this);
exit1 = new JButton("Exit");
exit1.setForeground(Color.white);
exit1.setBackground(Color.black);
exit1.addActionListener(this);
sexit = new JButton("Exit");
panelLeft = new Panel(); //Define new panels
panelMiddle = new Panel();
panelRight = new Panel();
panelTop = new Panel();
panelBottom = new Panel();
panelW = new Panel();
aco = new Label("Adult, Child or OAP");
stitle = new Label("Seating");
stitle.setFont(new Font("Verdana", Font.BOLD,18));
moviec = new Label("Movies");
moviec.setFont(new Font("Verdana", Font.BOLD,18));
chooseTime = new TextField(7); //Define new text fields
chooseAge = new TextField(7);
movieInfo = new TextField();
public void paint(Graphics graf)
public void actionPerformed(ActionEvent ev)
if (ev.getSource() == next) //if next button is pressed
mSelect = new Frame("Movie Page"); //Define frame
mSelect.setLayout(new FlowLayout()); //Set layout
mSelect.setVisible(true); //Frame is visible
mSelect.setSize(150,300); //Set the size of the frame
mSelect.setBackground(Color.green); //Background colour of the frame
mSelect.add(moviec); //Add labels
mSelect.add(movieselect);
mSelect.add(movies);
mSelect.add(new Label("Select time: 1, 3, 5, 7, 9"));
mSelect.add(chooseTime); //Add text field
mSelect.add(new Label("Adult, Child or OAP?"));
mSelect.add(chooseAge);
mSelect.add(seating); //Add JButton
mSelect.add(exit1);
else
setVisible(false); //Frame is insivible and there's no size
setSize(0,0);
if (ev.getSource() == seating)
seatdisplay = new Frame("Seating Display");
seatdisplay.setLayout(new BorderLayout()); //Define border layout
seatdisplay.setVisible(true);
seatdisplay.setBackground(Color.green);
seatdisplay.setSize(550,500);
seatdisplay.add(panelLeft, BorderLayout.WEST); //Position object to the west
seatdisplay.add(panelMiddle, BorderLayout.CENTER);
seatdisplay.add(panelRight, BorderLayout.EAST);
seatdisplay.add(panelTop, BorderLayout.NORTH);
seatdisplay.add(panelBottom, BorderLayout.SOUTH);
panelLeft.setLayout(new GridLayout(4,2)); //Define new grid layout
panelLeft.add(a1 = new JButton("A1")); //Add buttons
panelLeft.add(a2 = new JButton("A2"));
panelLeft.add(a3 = new JButton("A3"));
panelLeft.add(a4 = new JButton("A4"));
panelLeft.add(a5 = new JButton("A5"));
panelLeft.add(a6 = new JButton("A6"));
panelLeft.add(a7 = new JButton("A7"));
panelLeft.add(a8 = new JButton("A8"));
panelMiddle.setLayout(new GridLayout(3,6));
panelMiddle.add(empty = new JButton("")); empty.setVisible(false);
panelMiddle.add(b1 = new JButton("B1"));
panelMiddle.add(b2 = new JButton("B2"));
panelMiddle.add(b3 = new JButton("B3"));
panelMiddle.add(b4 = new JButton("B4"));
panelMiddle.add(empty3 = new JButton("")); empty3.setVisible(false);
panelMiddle.add(empty1 = new JButton("")); empty1.setVisible(false);
panelMiddle.add(b5 = new JButton("B5"));
panelMiddle.add(b6 = new JButton("B6"));
panelMiddle.add(b7 = new JButton("B7"));
panelMiddle.add(b8 = new JButton("B8"));
panelMiddle.add(empty4 = new JButton("")); empty4.setVisible(false);
panelMiddle.add(empty2 = new JButton("")); empty2.setVisible(false);
panelMiddle.add(b9 = new JButton("B9"));
panelMiddle.add(b10 = new JButton("B10"));
panelMiddle.add(b11 = new JButton("B11"));
panelMiddle.add(b12 = new JButton("B12"));
panelRight.setLayout(new GridLayout(4,2));
panelRight.add(c1 = new JButton("C1"));
panelRight.add(c2 = new JButton("C2"));
panelRight.add(c3 = new JButton("C3"));
panelRight.add(c4 = new JButton("C4"));
panelRight.add(c5 = new JButton("C5"));
panelRight.add(c6 = new JButton("C6"));
panelRight.add(c7 = new JButton("C7"));
panelRight.add(c8 = new JButton("C8"));
// t = Integer.parseInt(chooseTime.getText()); //Convert vlaue into integer
movieInfo = new TextField("Movie: " + movies.getSelectedItem() + " Time: "
+ chooseTime.getText() + "pm" + " Age: " + chooseAge.getText()); /* Concatenate
strings together */
panelBottom.add(movieInfo); movieInfo.setEditable(false); //add non editable text field
movieInfo.setBackground(Color.black); movieInfo.setForeground(Color.yellow);
panelBottom.add(calcost = new JButton("Calculate Cost"));
panelBottom.add(exit2 = new JButton("Exit"));
panelTop.setLayout(new FlowLayout());
panelTop.add(stitle);
calcost.addActionListener(this); exit2.addActionListener(this);
a1.addActionListener(this); c1.addActionListener(this);
a2.addActionListener(this); c2.addActionListener(this);
a3.addActionListener(this); c3.addActionListener(this);
a4.addActionListener(this); c4.addActionListener(this);
a5.addActionListener(this); c5.addActionListener(this);
a6.addActionListener(this); c6.addActionListener(this);
a7.addActionListener(this); c7.addActionListener(this);
a8.addActionListener(this); c8.addActionListener(this);
b1.addActionListener(this); b2.addActionListener(this);
b3.addActionListener(this); b4.addActionListener(this);
b5.addActionListener(this); b6.addActionListener(this);
b7.addActionListener(this); b8.addActionListener(this);
b9.addActionListener(this); b10.addActionListener(this);
b11.addActionListener(this); b12.addActionListener(this);
a1.setBackground(Color.black); a1.setForeground(Color.white);
a2.setBackground(Color.black); a2.setForeground(Color.white);
a3.setBackground(Color.black); a3.setForeground(Color.white);
a4.setBackground(Color.black); a4.setForeground(Color.white);
a5.setBackground(Color.black); a5.setForeground(Color.white);
a6.setBackground(Color.black); a6.setForeground(Color.white);
a7.setBackground(Color.black); a7.setForeground(Color.white);
a8.setBackground(Color.black); a8.setForeground(Color.white);
b1.setBackground(Color.black); b1.setForeground(Color.white);
b2.setBackground(Color.black); b2.setForeground(Color.white);
b3.setBackground(Color.black); b3.setForeground(Color.white);
b4.setBackground(Color.black); b4.setForeground(Color.white);
b5.setBackground(Color.black); b5.setForeground(Color.white);
b6.setBackground(Color.black); b6.setForeground(Color.white);
b7.setBackground(Color.black); b7.setForeground(Color.white);
b8.setBackground(Color.black); b8.setForeground(Color.white);
b9.setBackground(Color.black); b9.setForeground(Color.white);
b10.setBackground(Color.black); b10.setForeground(Color.white);
b11.setBackground(Color.black); b11.setForeground(Color.white);
b12.setBackground(Color.black); b12.setForeground(Color.white);
c1.setBackground(Color.black); c1.setForeground(Color.white);
c2.setBackground(Color.black); c2.setForeground(Color.white);
c3.setBackground(Color.black); c3.setForeground(Color.white);
c4.setBackground(Color.black); c4.setForeground(Color.white);
c5.setBackground(Color.black); c5.setForeground(Color.white);
c6.setBackground(Color.black); c6.setForeground(Color.white);
c7.setBackground(Color.black); c7.setForeground(Color.white);
c8.setBackground(Color.black); c8.setForeground(Color.white);
if (ev.getSource() == exit1)
mSelect.setVisible(false);
mSelect.setSize(0,0);
if (ev.getSource() == exit2)
seatdisplay.setVisible(false);
if (ev.getSource() == a1)
a1.setBackground(Color.red);
class Ticket
public Ticket()
public Ticket(char age, int time, double seat)
ageGroup = age;
filmTime = time;
chSeat = seat;
public char displayAge()
return ageGroup;
public int displayTime()
return filmTime;
public double chargeSeat()
return chSeat;
}
Similar Messages
-
Classpath/appletviewer problem
Help please!
I have an appletviewer run-time problem with classpath.
I have compiled a package called "MyClass" as the following.
C:\jsdk\source>javac -d "c:\jsdk\jre\classes" MyClass.java
and MyClass.class file has been created in
c:\jsdk\jre\class
then I compiled a program called as JavaProg.java successfully using the following command.
C:\jsdk\source>javac -classpath "c:\jsdk\jre\classes" JavaProg.java
classpath has been set as:
SET CLASSPATH=.;c:\jsdk\jre\classes
SET CLASSPATH=%CLASSPATH%;.:C:/jsdk/applet/bin
(I downloaded 1.4.0_01 as the fllowing:
"SDK" to C:\jsdk
"JRE" to C:\windows\applet)
When I issued the following command
c:\jsdk\source>appletviewer JavaProg.html
I received the following error message.
java.lang.NoClassDefFoundError: org/name/JavaProg
at JavaProg.init(JavaProg.java:22)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Programs similar to the JavaProg that do not use JApplet run successfully.
What do I need to do to run "appletviewer" successfully?
Thank you very much for your help in advance!In general, put the html and class files in the same directory. If you're using codebase or documentbase tags in the html, or using packages, you need to understand first how java works.
Here's references that you should read:
Setting the Classpath:
http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/classpath.html
[NOTE: always start your classpath with ".;" which means the current directory.]
How Classes are Found:
http://java.sun.com/j2se/1.4.1/docs/tooldocs/findingclasses.html
And here's my attempt to explain packages:
Assume that your programs are part of a package named divelog, which is specified by the first line in each source file: package divelog;
Also assume that this directory (C:\javaT\myWork\) is part of the CLASSPATH list of directories.
Also assume that all the source files reside in this directory structure: C:\javaT\myWork\divelog\
Then a statement to compile a source file Named Divelog.java is:
C:\JavaT\myWork\>javac divelog\Divelog.java
Explanation:
Java starts looking for classes in the directory(s) listed in the classpath. In this case, one of the directories should be: C:\JavaT\myWork\ since it contains your divelog package.
Compiling
A class can either be part of a package (ie, no package statement at the top of the class.), or not.
If the class is not part of a package: Its source file needs to be in one of the classpath directories. To compile you use the command: javac SomeFile.java, from within the classpath directory that contains the file.
The class is part of a package (this case): The source file must be in a subdirectory structure that starts in one of the classpath directories. The subdirectory structure must match the package statement.
So, you generate a directory structure C:\javaT\myWork\divelog\ which is the [classpath directory + the package subdirectory structure], and place Divelog.java in it.
Then from the classpath directory (C:\JavaT\myWork\) use the command: javac divelog\Divelog.java
This creates a file, Divelog.class in the divelog directory. (The following is where people tend to get lost.) The correct name now, as far as java is concerned, is the combination of package name and class name: divelog.Divelog (note I omit the .class)
Running
To run a class that's not part of a package: From within the classpath directory that contains the class. use the command: java SomeFile
To run a class that is part of a package: From within the classpath directory (C:\JavaT\myWork\) use the command java divelog.Divelog (Note that this is analogous to the command for a class not in a package, you just use the fully qualified name) -
Appletviewer Problem. Please help!
I had JRE 6 update 5. I wanted to try out appletviewer, so downloaded JDK. But this was version 1.4.2_17. Appletviewer did not work, saying registry value is 1.6 whereas it should be 1.4, & it cannot find java.dll & Java 2 runtime environment. So I uninstalled everything, & reinstalled JDK 1.4.2_17. APPLETVIEWER WORKED. But when I went to Java website to check latest version, it said you don't have latest version. So I fished for latest version of JDK, found, downloaded & installed jdk-6u5-windows-i586-p.exe, after uninstalling 1.4.2_17. Now again appletviewer has stopped working & gives the same error message about registry (1.6 instead of 1.4), java.dll not found & Java 2 RE not found. Tried adding Java bin path in system environment variable. Did not work. Please help. Is this a bug in JDK 6 update 5?
Coming somewhat closer to the solution
You understand that JDK and JRE both are differently installed.
Not to panic.You can install JRE of 1.4 and then set your class path to that jre 1.4.
Hope you got the point where you're missing.
good luck. -
I am writing a program that should allow me to communicate between applet. The applet is loaded via the a web site, but i can't get that to work, so i am using appletviewer instead.
I want to establish a connection between the applets thus allowing to chat.
So far i can open both applets up, (using localhost), but the applet isn't able to establish the connection and i have to turn off one of the applet window, before i get a connection, but it won't do anything after that.
I know it is a security problem, but how can i fix this problem.
Please can you help, i am in difficult position
JunaidI think what u are trying to do is some peer-to-peer communication using applets.
The thing is the applet knows ( via getCodeBase and getDocumentBase methods) from where it was launched. It has no knowledge of where other applets from the same server may be residing.
It looks to me that you will need to do some server-side coding as well..
On possible solution would be to
A) Install and run a Tomcat Server
B) Tomcat can be used as a webserver in limited way .. (refer it documentation ) by defaul it runs on port 8080
C) So you can say http://localhost:8080/
D) Use this launch the applets
E) Using HTTP Tunneling ( Read about it in Servlets ) you can set up Tomcat to broker messages between the 2 applets
Also from you question it appear that both the applets try to hook on the same port, now on one computer (localhost) one port can be used by one socket . Try to get them to use different ports then the appletviewer problems should solve it self.
To use different ports without making 2 different applets , simeply pass the port as a PARAM to the applet -
Compiling on xp is no problem but I cannot start my appletviewer
I can compile on xp but I cannot start my applets, in DOS
example :
c:\BIN> appletviewer balloon.html
c:\BIN>
After this nothing happens..
I mean it does something but it does not start the applet.
I tried everything looking up in the advanced browser configuration but could not find any problems there.
It does compile and seems to accept the appletviewer command but does not execute it like it is supposed to.
I really hope that u or someone else has a solution to this problem.Hello abbas_bokhary,
Have you tried running some of the standard demo Applets with appletviewer? Or have you run your Applet with Netscape Browser?
-Merwyn,
Developer Technical Support,
http://www.sun.com/developers/support. -
Problem: displayed output in appletviewer vs internet explorer
I am new to Java programming, having recently completed by first class. I have been trying to set up the Java Development Kit on my PC at home. I installed J2SDK1.4.1_01 and edited my autoexec.bat file to: (1) add ;C:\J2SDK1.4.1_01/BIN to the PATH statement and (2) create a CLASSPATH statement: SET CLASSPATH=;.;
I been using old programs from class to test the install and have encountered a problem. I recompiled a program which outputs an applet. I can view the applet in Appletviewer, but when I go to view it in Internet Explorer, I see only a gray rectangular box.
I tried a slightly different program which, in addition to producing an applet, also (in the html code) prints different sized heading lines.
I see the applet only in Appletviewer. In Internet Explorer, I see the heading lines and a retangular gray box. Both this and the first program import java/awt/Graphics.
I have tried variations for CLASSPATH such as SET CLASSPATH=;.;C:\J2SDK1.4.1_01 AND C=;.;C:\WINDOWS\JAVA\PACKAGES\zipfile (repeating the C:\WINDOWS... for each zipped file) .... nothing works
Can you give me an idea on what I need to do to fix this.Thanks for your suggestion to search the forum for similar problems. I went into the control panel to try and enable Java Plug-in. I found two Java Plugin icons. One was for an earlier version ... 1.3 and the other showed up as J2SDK1.4.1_01. I took the check off the 1.3 version to unenable it and went to enable the 1.4.1_01 plugin. The problem is, it had no enable check box. So I went to the advanced features of Internet Options to try and enable Java Plugin from there. Under Java(SUN) there was no listing for a Java JIT compiler to enable. There was a JIT Compiler which could be enabled under Microsoft VM. I didn't think it would work, but I tried enabling it and rebooting. ... I was still unable to see applets in IE. I then tried unenabling it with similar results.
Today, I uninstalled 1.3 and uninstalled/reinstalled 1.4.1_01 (without a problem) and rebooted. I went into the control panel to try and enable the Java Plugin (of which there was just 1 now), and it gave me this error message: The system cannot find the registry key specified // HKEY_LOCAL-Machine\Software\JavaSsoft\Java Plug-in\1.4.1-01.
Bottom line ... I still can't see applets in IE. I have tried finding the answer about the Key Registry problem in Forums, but I didn't see one that tied into my problem. Also, there is still no listing within the advanced features of Internet Options for Java (Sun) - JIT Compiler ...so I still can't enable it from there.
At this point, I don't know if I've inadverently done something to screw things up. I'd really like to start playing around in Java, but I can't until I have the system set up properly. Anyone have any ideas? -
Problem while I try to run Applet using Appletviewer
Hi,
I have developed a simple Applet using JDeveloper 1.1, here I am
using a Dataset, a QueryDataSet and a grid.
When I run the Applet within JDeveloper it runs just fine, but
when I use the Appletviewer, the Applet starts of well but gives
the following error:
"borland.jbcl.dataset.DataSetException: Operation cannot be
performed on an open DataSet"
Please let me know what I am doing wrong.
Thanks,
Prag.
nullThis may be a problem with JDK inconsistency problem. Make sure
your appletviewer IS Java 1.1 compliant. Also, have you properly
deployed your applet to a jar file?
Here are the instructions for deploying a database applet:
Hope this helps..
-Chris
Task 7: Deployment
The following requirements apply when deploying a database
applet:
The database must be on the same server as the Web Server (or use
a connection manager).
Must have a JDK 1.1 compatible browser, such as Netscape 4.0.4 or
Internet Explorer 4.0.
Creating the Java Archive (.jar) file
Select File|New
Click the Deployment tab
Double-click the Simple Archive Profile icon.
The Simple Archive Profile wizard (SAP wizard) is displayed.
On the Welcome page, click Next.
On page one of the SAP wizard, enter or browse to set the Archive
Path. Set the name of the jar to db_applet.jar.
Click Next.
Page two displays the names of all files in your project. Accept
the default value of deploying all of the files and click Next.
On page three, Dependencies, shift-click each item in the list
"List items that you do not want to appear in the archive to
select them all.
Click Remove.
In most cases, developers prefer to ship only their own classes
in the .jar file, with separate .jars that store common files
used by all of their Java programs. For the sake of simplicity,
you are going to create a .jar file that includes all of the
classes necessary to run your applet. By removing all of the
libraries, you indicate that no classes should be omitted from
your deployed .jar file.
Click Finish.
Deploying the applet
Using a file manager, copy the db_applet.jar file you have just
created to the Web Server.
Copy the tutorial.EmpApplet.html file to the same directory as
your .jar file.
The tutorial.EmpApplet.html file can be found in the project
directory (by default, the \myprojects directory under the
JDeveloper root directory) or you can extract the file from the
.jar using any PK-ZIP compatible file compression utility.
Using any text editor, modify the <APPLET> tag in the
tutorial.EmpApplet.html file to include an ARCHIVE tag that
references your .jar file. Your <APPLET> tag should include this
information:
<APPLET CODEBASE = "." CODE = "tutorial.EmpApplet.class"
NAME = "TestApplet" WIDTH = 400 HEIGHT = 300 HSPACE
= 0 VSPACE = 0 ALIGN = middle ARCHIVE =
"db_applet.jar">
To test the applet, open the tutorial.EmpApplet.html file through
a web server using a Java 1.1 enabled browser.
Congratulations! You have completed your first database applet.
You created a program that queries data from Oracle tables,
displays the data in data-aware controls, allows for viewing and
editing, displays status messages to a StatusBar, and includes a
NavigatorControl component.
Prag Ratra (guest) wrote:
: Hi,
: I have developed a simple Applet using JDeveloper 1.1, here I
am
: using a Dataset, a QueryDataSet and a grid.
: When I run the Applet within JDeveloper it runs just fine, but
: when I use the Appletviewer, the Applet starts of well but
gives
: the following error:
: "borland.jbcl.dataset.DataSetException: Operation cannot be
: performed on an open DataSet"
: Please let me know what I am doing wrong.
: Thanks,
: Prag.
null -
Problems with Reports and AppletViewer
Hi:
I'm using Netscape 4.7 and JInitiator 1.1.7.18, but I3ve two more
questions:
1.- Using JInitiator, I've a poor performance, works two or three
times, then it crashes. Do you have this problem?
2.- Instead of JInitiator, I've to use Appletviewer (JDK 1.1.7),
works much better and the performance is higher, but a calling to
a WebReport using web.show_document built-in doesn't work. How
can I run a WebReport using the Appletviewer?
Thanks.
Polo Alvarez
nullOK, finally solved the problem... A good night's sleep always helps ;).
After just trying each queried table one after an other, I found the problem:
The difference between Oracle Apps (Dutch locale) and the reports builder (English) is the language... And our functional people have changed some names, but the Dutch ones, leaving the english names in place and one of the tables I query has language specific data, which is also appears in a where clause. -
Problem with AppletViewer in Forte
Hi,
my applet runs fine when the 1.4 appletviewer is called from the command line, it also runs fine when executing the forte-generated html-file from forte, but the appletviewer won't start from forte (applet debugging and applet execution set)
when i try to execute my applet from forte, the process starts, runs 1 or two seconds, and terminates without showing any messages (errormessages).
any ideas? thanks in advance...J2ME forte integration destroyed something in my forte-projects-folder. Uninstall was not enough, i had to rename this folder and create a new one.
-
Problem with appletViewer.exe
After installed JDK1.4.1 on my system (Win2000, SP3), I tried to run a very simple java applet. But I got the exception like the following:
F:\javaTest>appletviewer Hello.html
Exception in thread "main" java.util.MissingResourceException: Can't find resource for bundle sun.applet.resources.MsgA
pletViewer, key appletpanel.badattribute.exception
at java.util.ResourceBundle.getObject(ResourceBundle.java:314)
at java.util.ResourceBundle.getString(ResourceBundle.java:274)
at sun.applet.AppletMessageHandler.getMessage(AppletMessageHandler.java:39)
at sun.applet.AppletPanel.showAppletStatus(AppletPanel.java:755)
at sun.applet.AppletPanel.init(AppletPanel.java:190)
at sun.applet.AppletViewer.<init>(AppletViewer.java:177)
at sun.applet.StdAppletViewerFactory.createAppletViewer(AppletViewer.java:82)
at sun.applet.AppletViewer.parse(AppletViewer.java:1122)
at sun.applet.AppletViewer.parse(AppletViewer.java:1056)
at sun.applet.Main.run(Main.java:138)
at sun.applet.Main.main(Main.java:80)
Anyone has idea what's the cause?
Thanks in advanced.http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Bappletviewer%2C+%2B%22find+resource+for+bundle%22&col=javaforums&x=25&y=9
-
I am typing the exact path to my class file and I get this error.....
I/O exception while reading "C:\Blah, blah" (The filename, directory name or volume doesn't exist)
WHY!!!!!??? I am cutting and pasting the path into the dos prompt.The appletviewer program expects to get a HTML file as a parameter, not a class file.
Actually the file type does not matter; appletviewer only checks if it has any <applet>-tags and tries to start the applets. .class files usually don't have <applet>-tags, so the program exits silently.
Don't you get the "I/O exception" anymore? -
Game not loading; font problem
I am not a Java programmer or trying to be one (SQL is enough fun for now.) I'm just trying to play a little game.
http://infsoc.sub.jp/soft/esc2/esc2.html
I get a box with a red X top left corner, and the Java console reads:
java.lang.ExceptionInInitializerError
at hsplet.variable.StringArray.<init>(StringArray.java:52)
at hsplet.variable.StringArray.<init>(StringArray.java:31)
at hsplet.Context.<init>(Context.java:211)
at hsplet.Applet.<init>(Applet.java:42)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(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.nio.charset.UnsupportedCharsetException: MS932
at java.nio.charset.Charset.forName(Unknown Source)
at hsplet.variable.ByteString.<clinit>(ByteString.java:31)
... 15 more
From the last bit it looks like I'm missing a Japanese font or character set. From my end -- as the stupid user -- how can I fix this? If the charset is the problem, can I find out which charset is missing and install it?
I have Windows MCE and Java Plug-in 1.6.0_02. I've googled around for UnsupportedCharsetException and can't find anything useful to me. Thanks.Oh right! We didn't solve your problem for you so we must be a bunch of losers who have no idea. Gee nobody has ranted and raved like that before. Try getting some new material.
BTW: it has nothing to do with if we do/do not know how to solve the problem. It has everything to do with this is not the correct place to ask! So sod off dickwad. -
Problem converting a (working) Java program into an applet
When I'm trying to access an Image through a call to :
mediaTracker = new MediaTracker(this);
backGroundImage = getImage(getDocumentBase(), "background.gif");
mediaTracker.addImage(backGroundImage, 0);
I'm getting a nullPointerException as a result of the call to getDocumentBase() :
C:\Chantier\Java\BallsApplet
AppletViewer testBallsApplet.htmljava.lang.NullPointerException
at java.applet.Applet.getDocumentBase(Applet.java:125)
at Balls.<init>(Balls.java:84)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:296)
at java.lang.Class.newInstance(Class.java:249)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
at sun.applet.AppletPanel.run(AppletPanel.java:290)
at java.lang.Thread.run(Thread.java:536)
It seems very weird to me... :-/
(all the .gif files are in the same directory than the .class files)
The problem appears with AppletViewer trying to open an HTML file
containing :
<HTML>
<APPLET CODE="Balls.class" WIDTH=300 HEIGHT=211>
</APPLET>
</HTML>
(I tried unsuccessfully the CODEBASE and ARCHIVE attributes, with and without putting the .gif and .class into a .jar file)
I can't find the solution by myself, so, I'd be very glad if someone could help
me with this... Thank you very much in advance ! :-)
You'll find below the source of a small game that I wrote and debugged (without
problem) and that I'm now (unsuccessfully) trying to convert into an Applet :
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.net.URL;
public class Balls extends java.applet.Applet implements Runnable, KeyListener
private Image offScreenImage;
private Image backGroundImage;
private Image[] gifImages = new Image[6];
private Image PressStart ;
private Sprite pressStartSprite = null ;
private Image YouLose ;
private Sprite YouLoseSprite = null ;
private Image NextStage ;
private Sprite NextStageSprite = null ;
private Image GamePaused ;
private Sprite GamePausedSprite = null ;
//offscreen graphics context
private Graphics offScreenGraphicsCtx;
private Thread animationThread;
private MediaTracker mediaTracker;
private SpriteManager spriteManager;
//Animation display rate, 12fps
private int animationDelay = 83;
private Random rand = new Random(System.currentTimeMillis());
private int message = 0 ; // 0 = no message (normal playing phase)
// 1 = press space to start
// 2 = press space for next level
// 3 = game PAUSED, press space to unpause
// 4 = You LOSE
public static void main(String[] args)
try
new Balls() ;
catch (java.net.MalformedURLException e)
System.out.println(e);
}//end main
public void start()
//Create and start animation thread
animationThread = new Thread(this);
animationThread.start();
public void init()
try
new Balls() ;
catch (java.net.MalformedURLException e)
System.out.println(e);
public Balls() throws java.net.MalformedURLException
{//constructor
// Load and track the images
mediaTracker = new MediaTracker(this);
backGroundImage = getImage(getDocumentBase(), "background.gif");
mediaTracker.addImage(backGroundImage, 0);
PressStart = getImage(getDocumentBase(), "press_start.gif");
mediaTracker.addImage(PressStart, 0);
NextStage = getImage(getDocumentBase(), "stage_complete.gif");
mediaTracker.addImage(NextStage, 0);
GamePaused = getImage(getDocumentBase(), "game_paused.gif");
mediaTracker.addImage(GamePaused, 0);
YouLose = getImage(getDocumentBase(), "you_lose.gif");
mediaTracker.addImage(YouLose, 0);
//Get and track 6 images to use
// for sprites
gifImages[0] = getImage(getDocumentBase(), "blueball.gif");
mediaTracker.addImage(gifImages[0], 0);
gifImages[1] = getImage(getDocumentBase(), "redball.gif");
mediaTracker.addImage(gifImages[1], 0);
gifImages[2] = getImage(getDocumentBase(), "greenball.gif");
mediaTracker.addImage(gifImages[2], 0);
gifImages[3] = getImage(getDocumentBase(), "yellowball.gif");
mediaTracker.addImage(gifImages[3], 0);
gifImages[4] = getImage(getDocumentBase(), "purpleball.gif");
mediaTracker.addImage(gifImages[4], 0);
gifImages[5] = getImage(getDocumentBase(), "orangeball.gif");
mediaTracker.addImage(gifImages[5], 0);
//Block and wait for all images to
// be loaded
try {
mediaTracker.waitForID(0);
}catch (InterruptedException e) {
System.out.println(e);
}//end catch
//Base the Frame size on the size
// of the background image.
//These getter methods return -1 if
// the size is not yet known.
//Insets will be used later to
// limit the graphics area to the
// client area of the Frame.
int width = backGroundImage.getWidth(this);
int height = backGroundImage.getHeight(this);
//While not likely, it may be
// possible that the size isn't
// known yet. Do the following
// just in case.
//Wait until size is known
while(width == -1 || height == -1)
System.out.println("Waiting for image");
width = backGroundImage.getWidth(this);
height = backGroundImage.getHeight(this);
}//end while loop
//Display the frame
setSize(width,height);
setVisible(true);
//setTitle("Balls");
//Anonymous inner class window
// listener to terminate the
// program.
this.addWindowListener
(new WindowAdapter()
{public void windowClosing(WindowEvent e){System.exit(0);}});
// Add a key listener for keyboard management
this.addKeyListener(this);
}//end constructor
public void run()
Point center_place = new Point(
backGroundImage.getWidth(this)/2-PressStart.getWidth(this)/2,
backGroundImage.getHeight(this)/2-PressStart.getHeight(this)/2) ;
pressStartSprite = new Sprite(this, PressStart, center_place, new Point(0, 0),true);
center_place = new Point(
backGroundImage.getWidth(this)/2-NextStage.getWidth(this)/2,
backGroundImage.getHeight(this)/2-NextStage.getHeight(this)/2) ;
NextStageSprite = new Sprite(this, NextStage, center_place, new Point(0, 0),true);
center_place = new Point(
backGroundImage.getWidth(this)/2-GamePaused.getWidth(this)/2,
backGroundImage.getHeight(this)/2-GamePaused.getHeight(this)/2) ;
GamePausedSprite = new Sprite(this, GamePaused, center_place, new Point(0, 0),true);
center_place = new Point(
backGroundImage.getWidth(this)/2-YouLose.getWidth(this)/2,
backGroundImage.getHeight(this)/2-YouLose.getHeight(this)/2) ;
YouLoseSprite = new Sprite(this, YouLose, center_place, new Point(0, 0),true);
BackgroundImage bgimage = new BackgroundImage(this, backGroundImage) ;
for (;;) // infinite loop
long time = System.currentTimeMillis();
message = 1 ; // "press start to begin"
while (message != 0)
repaint() ;
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
boolean you_lose = false ;
for (int max_speed = 7 ; !you_lose && max_speed < 15 ; max_speed++)
for (int difficulty = 2 ; !you_lose && difficulty < 14 ; difficulty++)
boolean unfinished_stage = true ;
spriteManager = new SpriteManager(bgimage);
spriteManager.setParameters(difficulty, max_speed) ;
//Create 15 sprites from 6 gif
// files.
for (int cnt = 0; cnt < 15; cnt++)
if (cnt == 0)
Point position = new Point(
backGroundImage.getWidth(this)/2-gifImages[0].getWidth(this)/2,
backGroundImage.getHeight(this)/2-gifImages[0].getHeight(this)/2) ;
spriteManager.addSprite(makeSprite(position, 0, false));
else
Point position = spriteManager.
getEmptyPosition(new Dimension(gifImages[0].getWidth(this),
gifImages[0].getHeight(this)));
if (cnt < difficulty)
spriteManager.addSprite(makeSprite(position, 1, true));
else
spriteManager.addSprite(makeSprite(position, 2, true));
}//end for loop
time = System.currentTimeMillis();
while (!spriteManager.getFinishedStage() && !spriteManager.getGameOver())
// Loop, sleep, and update sprite
// positions once each 83
// milliseconds
spriteManager.update();
repaint();
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
}//end while loop
if (spriteManager.getGameOver())
message = 4 ;
while (message != 0)
spriteManager.update();
repaint();
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
you_lose = true ;
if (spriteManager.getFinishedStage())
message = 2 ;
while (message != 0)
spriteManager.update();
repaint();
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
} // end for difficulty loop
} // end for max_speed
} // end infinite loop
}//end run method
private Sprite makeSprite(Point position, int imageIndex, boolean wind)
return new Sprite(
this,
gifImages[imageIndex],
position,
new Point(rand.nextInt() % 5,
rand.nextInt() % 5),
wind);
}//end makeSprite()
//Overridden graphics update method
// on the Frame
public void update(Graphics g)
//Create the offscreen graphics
// context
if (offScreenGraphicsCtx == null)
offScreenImage = createImage(getSize().width,
getSize().height);
offScreenGraphicsCtx = offScreenImage.getGraphics();
}//end if
if (message == 0)
// Draw the sprites offscreen
spriteManager.drawScene(offScreenGraphicsCtx);
else if (message == 1)
pressStartSprite.drawSpriteImage(offScreenGraphicsCtx);
else if (message == 2)
NextStageSprite.drawSpriteImage(offScreenGraphicsCtx);
else if (message == 3)
GamePausedSprite.drawSpriteImage(offScreenGraphicsCtx);
else if (message == 4)
YouLoseSprite.drawSpriteImage(offScreenGraphicsCtx);
// Draw the scene onto the screen
if(offScreenImage != null)
g.drawImage(offScreenImage, 0, 0, this);
}//end if
}//end overridden update method
//Overridden paint method on the
// Frame
public void paint(Graphics g)
//Nothing required here. All
// drawing is done in the update
// method above.
}//end overridden paint method
// Methods to handle Keyboard event
public void keyPressed(KeyEvent evt)
int key = evt.getKeyCode(); // Keyboard code for the pressed key.
if (key == KeyEvent.VK_SPACE)
if (message != 0)
message = 0 ;
else
message = 3 ;
if (key == KeyEvent.VK_LEFT)
if (spriteManager != null)
spriteManager.goLeft() ;
else if (key == KeyEvent.VK_RIGHT)
if (spriteManager != null)
spriteManager.goRight() ;
else if (key == KeyEvent.VK_UP)
if (spriteManager != null)
spriteManager.goUp() ;
else if (key == KeyEvent.VK_DOWN)
if (spriteManager != null)
spriteManager.goDown() ;
if (spriteManager != null)
spriteManager.setMessage(message) ;
public void keyReleased(KeyEvent evt)
public void keyTyped(KeyEvent e)
char key = e.getKeyChar() ;
//~ if (key == 's')
//~ stop = true ;
//~ else if (key == 'c')
//~ stop = false ;
//~ spriteManager.setStop(stop) ;
}//end class Balls
//===================================//
class BackgroundImage
private Image image;
private Component component;
private Dimension size;
public BackgroundImage(
Component component,
Image image)
this.component = component;
size = component.getSize();
this.image = image;
}//end construtor
public Dimension getSize(){
return size;
}//end getSize()
public Image getImage(){
return image;
}//end getImage()
public void setImage(Image image){
this.image = image;
}//end setImage()
public void drawBackgroundImage(Graphics g)
g.drawImage(image, 0, 0, component);
}//end drawBackgroundImage()
}//end class BackgroundImage
//===========================
class SpriteManager extends Vector
private BackgroundImage backgroundImage;
private boolean finished_stage = false ;
private boolean game_over = false ;
private int difficulty ;
private int max_speed ;
public boolean getFinishedStage()
finished_stage = true ;
for (int cnt = difficulty ; cnt < size(); cnt++)
Sprite sprite = (Sprite)elementAt(cnt);
if (!sprite.getEaten())
finished_stage = false ;
return finished_stage ;
public boolean getGameOver() {return game_over ;}
public void setParameters(int diff, int speed)
difficulty = diff ;
max_speed = speed ;
finished_stage = false ;
game_over = false ;
Sprite sprite;
for (int cnt = 0;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
sprite.setSpeed(max_speed) ;
public SpriteManager(BackgroundImage backgroundImage)
this.backgroundImage = backgroundImage ;
}//end constructor
public Point getEmptyPosition(Dimension spriteSize)
Rectangle trialSpaceOccupied = new Rectangle(0, 0,
spriteSize.width,
spriteSize.height);
Random rand = new Random(System.currentTimeMillis());
boolean empty = false;
int numTries = 0;
// Search for an empty position
while (!empty && numTries++ < 100)
// Get a trial position
trialSpaceOccupied.x =
Math.abs(rand.nextInt() %
backgroundImage.
getSize().width);
trialSpaceOccupied.y =
Math.abs(rand.nextInt() %
backgroundImage.
getSize().height);
// Iterate through existing
// sprites, checking if position
// is empty
boolean collision = false;
for(int cnt = 0;cnt < size(); cnt++)
Rectangle testSpaceOccupied = ((Sprite)elementAt(cnt)).getSpaceOccupied();
if (trialSpaceOccupied.intersects(testSpaceOccupied))
collision = true;
}//end if
}//end for loop
empty = !collision;
}//end while loop
return new Point(trialSpaceOccupied.x, trialSpaceOccupied.y);
}//end getEmptyPosition()
public void update()
Sprite sprite;
// treat special case of sprite #0 (the player)
sprite = (Sprite)elementAt(0);
sprite.updatePosition() ;
int hitIndex = testForCollision(sprite);
if (hitIndex != -1)
if (hitIndex < difficulty)
{ // if player collides with an hunter (red ball), he loose
sprite.setEaten() ;
game_over = true ;
else
// if player collides with an hunted (green ball), he eats the green
((Sprite)elementAt(hitIndex)).setEaten() ;
//Iterate through sprite list
for (int cnt = 1;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
//Update a sprite's position
sprite.updatePosition();
//Test for collision. Positive
// result indicates a collision
hitIndex = testForCollision(sprite);
if (hitIndex >= 0)
//a collision has occurred
bounceOffSprite(cnt,hitIndex);
}//end if
}//end for loop
}//end update
public void setMessage(int message)
Sprite sprite;
//Iterate through sprite list
for (int cnt = 0;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
//Update a sprite's stop status
sprite.setMessage(message);
}//end for loop
}//end update
public void goLeft()
Sprite sprite = (Sprite)elementAt(0);
sprite.goLeft() ;
public void goRight()
Sprite sprite = (Sprite)elementAt(0);
sprite.goRight() ;
public void goUp()
Sprite sprite = (Sprite)elementAt(0);
sprite.goUp() ;
public void goDown()
Sprite sprite = (Sprite)elementAt(0);
sprite.goDown() ;
private int testForCollision(Sprite testSprite)
//Check for collision with other
// sprites
Sprite sprite;
for (int cnt = 0;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
if (sprite == testSprite)
//don't check self
continue;
//Invoke testCollision method
// of Sprite class to perform
// the actual test.
if (testSprite.testCollision(sprite))
//Return index of colliding
// sprite
return cnt;
}//end for loop
return -1;//No collision detected
}//end testForCollision()
private void bounceOffSprite(int oneHitIndex, int otherHitIndex)
//Swap motion vectors for
// bounce algorithm
Sprite oneSprite = (Sprite)elementAt(oneHitIndex);
Sprite otherSprite = (Sprite)elementAt(otherHitIndex);
Point swap = oneSprite.getMotionVector();
oneSprite.setMotionVector(otherSprite.getMotionVector());
otherSprite.setMotionVector(swap);
}//end bounceOffSprite()
public void drawScene(Graphics g)
//Draw the background and erase
// sprites from graphics area
//Disable the following statement
// for an interesting effect.
backgroundImage.drawBackgroundImage(g);
//Iterate through sprites, drawing
// each sprite
for (int cnt = 0;cnt < size(); cnt++)
((Sprite)elementAt(cnt)).drawSpriteImage(g);
}//end drawScene()
public void addSprite(Sprite sprite)
addElement(sprite);
}//end addSprite()
}//end class SpriteManager
//===================================//
class Sprite
private Component component;
private Image image;
private Rectangle spaceOccupied;
private Point motionVector;
private Rectangle bounds;
private Random rand;
private int message = 0 ; // number of message currently displayed (0 means "no message" = normal game)
private int max_speed = 7 ;
private boolean eaten = false ; // when a green sprite is eaten, it is no longer displayed on screen
private boolean wind = true ;
private boolean go_left = false ;
private boolean go_right = false ;
private boolean go_up = false ;
private boolean go_down = false ;
public Sprite(Component component,
Image image,
Point position,
Point motionVector,
boolean Wind
//Seed a random number generator
// for this sprite with the sprite
// position.
rand = new Random(position.x);
this.component = component;
this.image = image;
setSpaceOccupied(new Rectangle(
position.x,
position.y,
image.getWidth(component),
image.getHeight(component)));
this.motionVector = motionVector;
this.wind = Wind ;
//Compute edges of usable graphics
// area in the Frame.
int topBanner = ((Container)component).getInsets().top;
int bottomBorder = ((Container)component).getInsets().bottom;
int leftBorder = ((Container)component).getInsets().left;
int rightBorder = ((Container)component).getInsets().right;
bounds = new Rectangle( 0 + leftBorder, 0 + topBanner
, component.getSize().width - (leftBorder + rightBorder)
, component.getSize().height - (topBanner + bottomBorder));
}//end constructor
public void setMessage(int message_number)
message = message_number ;
public void setSpeed(int speed)
max_speed = speed ;
public void goLeft()
go_left = true ;
public void goRight()
go_right = true ;
public void goUp()
go_up = true ;
public void goDown()
go_down = true ;
public void setEaten()
eaten = true ;
setSpaceOccupied(new Rectangle(4000,4000,0,0)) ;
public boolean getEaten()
return eaten ;
public Rectangle getSpaceOccupied()
return spaceOccupied;
}//end getSpaceOccupied()
void setSpaceOccupied(Rectangle spaceOccupied)
this.spaceOccupied = spaceOccupied;
}//setSpaceOccupied()
public void setSpaceOccupied(
Point position){
spaceOccupied.setLocation(
position.x, position.y);
}//setSpaceOccupied()
public Point getMotionVector(){
return motionVector;
}//end getMotionVector()
public void setMotionVector(
Point motionVector){
this.motionVector = motionVector;
}//end setMotionVector()
public void setBounds(Rectangle bounds)
this.bounds = bounds;
}//end setBounds()
public void updatePosition()
Point position = new Point(spaceOccupied.x, spaceOccupied.y);
if (message != 0)
return ;
//Insert random behavior. During
// each update, a sprite has about
// one chance in 10 of making a
// random change to its
// motionVector. When a change
// occurs, the motionVector
// coordinate values are forced to
// fall between -7 and 7. This
// puts a cap on the maximum speed
// for a sprite.
if (!wind)
if (go_left)
motionVector.x -= 2 ;
if (motionVector.x < -15)
motionVector.x = -14 ;
go_left = false ;
if (go_right)
motionVector.x += 2 ;
if (motionVector.x > 15)
motionVector.x = 14 ;
go_right = false ;
if (go_up)
motionVector.y -= 2 ;
if (motionVector.y < -15)
motionVector.y = -14 ;
go_up = false ;
if (go_down)
motionVector.y += 2 ;
if (motionVector.y > 15)
motionVector.y = 14 ;
go_down = false ;
else if(rand.nextInt() % 7 == 0)
Point randomOffset =
new Point(rand.nextInt() % 3,
rand.nextInt() % 3);
motionVector.x += randomOffset.x;
if(motionVector.x >= max_speed)
motionVector.x -= max_speed;
if(motionVector.x <= -max_speed)
motionVector.x += max_speed ;
motionVector.y += randomOffset.y;
if(motionVector.y >= max_speed)
motionVector.y -= max_speed;
if(motionVector.y <= -max_speed)
motionVector.y += max_speed;
}//end if
//Move the sprite on the screen
position.translate(motionVector.x, motionVector.y);
//Bounce off the walls
boolean bounceRequired = false;
Point tempMotionVector = new Point(
motionVector.x,
motionVector.y);
//Handle walls in x-dimension
if (position.x < bounds.x)
bounceRequired = true;
position.x = bounds.x;
//reverse direction in x
tempMotionVector.x = -tempMotionVector.x;
else if ((position.x + spaceOccupied.width) > (bounds.x + bounds.width))
bounceRequired = true;
position.x = bounds.x +
bounds.width -
spaceOccupied.width;
//reverse direction in x
tempMotionVector.x =
-tempMotionVector.x;
}//end else if
//Handle walls in y-dimension
if (position.y < bounds.y)
bounceRequired = true;
position.y = bounds.y;
tempMotionVector.y = -tempMotionVector.y;
else if ((position.y + spaceOccupied.height)
> (bounds.y + bounds.height))
bounceRequired = true;
position.y = bounds.y +
bounds.height -
spaceOccupied.height;
tempMotionVector.y =
-tempMotionVector.y;
}//end else if
if(bounceRequired)
//save new motionVector
setMotionVector(
tempMotionVector);
//update spaceOccupied
setSpaceOccupied(position);
}//end updatePosition()
public void drawSpriteImage(Graphics g)
if (!eaten)
g.drawImage(image,
spaceOccupied.x,
spaceOccupied.y,
component);
}//end drawSpriteImage()
public boolean testCollision(Sprite testSprite)
//Check for collision with
// another sprite
if (testSprite != this)
return spaceOccupied.intersects(
testSprite.getSpaceOccupied());
}//end if
return false;
}//end testCollision
}//end Sprite class
//===================================//
Thanks for your help...Sorry,
Can you tell me how do you solve it because I have got the same problem.
Can you indicate me the topic where did you find solution.
Thank in advance. -
J2ee installation problem on windows ME
I have downloaded the j2sdkee1.3 and have set all of the variables but when I type in j2ee -verbose or j2ee.bat -verbose ( as I have read about in peoples past problems ). I get the lines
out of environment space *2
syntax error * 3
exception in thread 'main' java.lang.NoClassDefFoundError: / appletviewer
do I need to be in a specific directory to do this command?
I have tried many things and read a lot of the examples that are posted here but I have found nothing to help so far, please help,
Anthony.Thanx. I have done that and when I type the j2ee.bat -verbose now I get a screen that comes up and offers me a load of options, does this mean that the program has worked. Deploytool does the same and says that you can put -ui to get a userInterface but nothing happens when I type the command.
P.S. msdos prompt can sometimes print so much information that it goes of the screen. How can I look at this information ( cause there is no scrollbar like Im use to ). Also is there a copy like ctrl 'c' so that I can print out the information into here for example? -
Problem Launching Java Applet with Plug-in: Version 1.4.2_01
Hello out there:
I recently installed j2re-1.4.2_01 on my home computer but have been unable to access Web sites emmploying JAva applets. The following is an email exchange with Jeff Hall of Lowell Observatory, manager of an educational site hosted by Lowell, trying to resolve my problem. The messages are better understood if read in reverse order.
I'm hoping that someone will recognize the source of my problem and can recommmend a solution. I would appreciate any help offered.
Thanks,
Mike Coucke
Hi Jeff:
Well, I guess the problem lies with me somewhere. Here's my answer/status to your questions/suggestions:
1) I'm using MS Windows Me version 4.90.3000
2) I do have the directory C:\Windows\.jpi_cache\jar\, but the only thing in it is an empty folder labeled "1.0". The file LP.jar does not exist anywhere on my hard drive.
3) I tried several game sites that utilized Java applets and got the same results: the Java cup in the upper left corner followed a few seconds later by the red "X". So, evidently the problem is somewhere on my end.
I'm going to post our email exchanges in a Java Users Forum managed by Sun to see if anyone out there can solve my problem. However, if you have any more suggestions, I'll be glad to try them.
Thanks for the help.
Mike Coucke
[email protected]
----- Original Message -----
From: "Jeffrey Hall" <[email protected]>
To: "'Mike Coucke'" <[email protected]>
Sent: Friday, September 05, 2003 1:02 PM
Subject: RE: Registration with Lowell Education Online
Mike,
Rats! What version of Windows are you using? It's a little strange to
see the user directory set to C:\Windows; if you're using XP, I'd expect
it to be something like C:\Documents and Settings\Mike Coucke. In any
event, the output that is of concern is these two lines:
java.lang.ClassNotFoundException: LPRemote.class
Caused by: java.net.UnknownHostException: proxy
It looks like your browser is not finding our server's IP when it comes
time to download the necessary Java code.
LPRemote.class is the fundamental code that runs LOPARC, and your
browser should be downloading it automatically when you click connect.
LPRemote.class is stored along with a bunch of other classes in a file
called "LP.jar" that you download from our server. So, if you go to C:
in Windows Explorer and do a file search for LP.jar, you should find it.
On my machine, it's stored in a directory called ".jpi_cache\jar\" in my
user home directory. Let me know if you have this file, or the
jpi-cache directory.
One other thing you might try is going to a different site that you know
uses Java applets -- I think some of the online game rooms at Yahoo use
Java. See if other sites that use Java load correctly. Then we'll know
if it's our server specifically, or a more general problem on your end.
Jeff Hall
Lowell Observatory
Hello Jeff:
I still have the Java "blues". I followed your instructions, but am still unable to launch a LOPARC session. After an initial failure, I uninstalled all three Java versions I had (1.4.0, 1.4.1, 1.4.2), then reinstalled 1.4.2_01 from the Sun website.
Now, when I try to launch LOPARC, I initially get a blank window with the Java cup in the upper left corner. After about 20 seconds, the cup changes to a red "X". During those 20 seconds, the following appear in the IE message bar at the bottom of the window: "Applet LPRemote notinited" (their spelling) which changes to "Loading Java Applet Failed..." when the red "X" appears.
Following is a copy of the log from my Java Console during all of this:
Java(TM) Plug-in: Version 1.4.2_01
Using JRE version 1.4.2_01 Java HotSpot(TM) Client VM
User home directory = C:\WINDOWS
Proxy Configuration: Manual Configuration
Proxy: http=proxy,https=proxy,ftp=proxy,gopher=proxy
Proxy Overrides:
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
load: class LPRemote.class not found.
java.lang.ClassNotFoundException: LPRemote.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.net.UnknownHostException: proxy
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.plugin.net.protocol.http.HttpClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.http.HttpClient.privilegedOpenServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.plugin.net.protocol.http.HttpClient.<init>(Unknown Source)
at sun.plugin.net.protocol.http.HttpClient.New(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.createConnection(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(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
I followed this up by executing the following three console commands:
"dump system properties"
"dump classholder list"
"dump thread list"
and obtained the following listings:
Dump system properties ...
acl.read = +
acl.read.default =
acl.write = +
acl.write.default =
application.home = C:\PROGRA~1\JAVA\J2RE14~1.2_0
awt.toolkit = sun.awt.windows.WToolkit
browser = sun.plugin
browser.vendor = Sun Microsystems, Inc.
browser.version = 1.1
deployment.javaws.cache.dir = C:\WINDOWS\.javaws\cache
deployment.javaws.jre.0.enabled = true
deployment.javaws.jre.0.location = http://java.sun.com/products/autodl/j2se
deployment.javaws.jre.0.osarch = x86
deployment.javaws.jre.0.osname = Windows
deployment.javaws.jre.0.path = C:\Program Files\Java\j2re1.4.2_01\bin\javaw.exe
deployment.javaws.jre.0.platform = 1.4
deployment.javaws.jre.0.product = 1.4.2_01
deployment.javaws.jre.0.registered = true
deployment.javaws.version = javaws-1.4.2_01
deployment.system.cacerts = C:\PROGRA~1\JAVA\J2RE14~1.2_0\lib\security\cacerts
deployment.system.home = C:\WINDOWS\Sun\Java\Deployment
deployment.system.jssecacerts = C:\PROGRA~1\JAVA\J2RE14~1.2_0\lib\security\cacerts
deployment.system.profile = C:\WINDOWS
deployment.system.security.policy = file:/C:/WINDOWS/Sun/Java/Deployment/security/java.policy
deployment.user.cachedir = C:\WINDOWS\Application Data\Sun\Java\Deployment\cache
deployment.user.certs = C:\WINDOWS\Application Data\Sun\Java\Deployment\security\deployment.certs
deployment.user.extdir = C:\WINDOWS\Application Data\Sun\Java\Deployment\ext
deployment.user.home = C:\WINDOWS\Application Data\Sun\Java\Deployment
deployment.user.jssecerts = C:\WINDOWS\Application Data\Sun\Java\Deployment\security\deployment.jssecerts
deployment.user.logdir = C:\WINDOWS\Application Data\Sun\Java\Deployment\log
deployment.user.profile = C:\WINDOWS\Application Data
deployment.user.security.policy = file:/C:/WINDOWS/Application%20Data/Sun/Java/Deployment/security/java.policy
deployment.user.tmpdir = C:\WINDOWS\Application Data\Sun\Java\Deployment\cache\tmp
file.encoding = Cp1252
file.encoding.pkg = sun.io
file.separator = \
file.separator.applet = true
http.agent = Mozilla/4.0 (Windows Me 4.90)
http.auth.serializeRequests = true
https.protocols = SSLv3,SSLv2Hello
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.awt.printerjob = sun.awt.windows.WPrinterJob
java.class.path = C:\PROGRA~1\JAVA\J2RE14~1.2_0\classes
java.class.version = 48.0
java.class.version.applet = true
java.endorsed.dirs = C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\endorsed
java.ext.dirs = C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\ext
java.home = C:\PROGRA~1\JAVA\J2RE14~1.2_0
java.io.tmpdir = C:\WINDOWS\TEMP\
java.library.path = D:\PROGRAM FILES\INTERNET EXPLORER 6;.;C:\WINDOWS\SYSTEM;C:\WINDOWS;D:\PROGRA~1\INTERN~1;;C:\WINDOWS;C:\WINDOWS\COMMAND
java.protocol.handler.pkgs = sun.plugin.net.protocol|sun.plugin.net.protocol
java.runtime.name = Java(TM) 2 Runtime Environment, Standard Edition
java.runtime.version = 1.4.2_01-b06
java.specification.name = Java Platform API Specification
java.specification.vendor = Sun Microsystems Inc.
java.specification.version = 1.4
java.util.prefs.PreferencesFactory = java.util.prefs.WindowsPreferencesFactory
java.vendor = Sun Microsystems Inc.
java.vendor.applet = true
java.vendor.url = http://java.sun.com/
java.vendor.url.applet = true
java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
java.version = 1.4.2_01
java.version.applet = true
java.vm.info = mixed mode
java.vm.name = Java HotSpot(TM) Client VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Sun Microsystems Inc.
java.vm.specification.version = 1.0
java.vm.vendor = Sun Microsystems Inc.
java.vm.version = 1.4.2_01-b06
javaplugin.maxHeapSize = 96m
javaplugin.nodotversion = 142_01
javaplugin.proxy.config.list = http=proxy,https=proxy,ftp=proxy,gopher=proxy
javaplugin.proxy.config.type = manual
javaplugin.version = 1.4.2_01
javaplugin.vm.options = -Djava.class.path=C:\PROGRA~1\JAVA\J2RE14~1.2_0\classes -Xbootclasspath/a:C:\PROGRA~1\JAVA\J2RE14~1.2_0\lib\plugin.jar -Xmx96m -Djavaplugin.maxHeapSize=96m -Xverify:remote -Djavaplugin.version=1.4.2_01 -Djavaplugin.nodotversion=142_01 -Dbrowser=sun.plugin -DtrustProxy=true -Dapplication.home=C:\PROGRA~1\JAVA\J2RE14~1.2_0 -Djava.protocol.handler.pkgs=sun.plugin.net.protocol
line.separator = \r\n
line.separator.applet = true
os.arch = x86
os.arch.applet = true
os.name = Windows Me
os.name.applet = true
os.version = 4.90
os.version.applet = true
package.restrict.access.netscape = false
package.restrict.access.sun = true
package.restrict.definition.java = true
package.restrict.definition.netscape = true
package.restrict.definition.sun = true
path.separator = ;
path.separator.applet = true
sun.arch.data.model = 32
sun.boot.class.path = C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\rt.jar;C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\i18n.jar;C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\sunrsasign.jar;C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\jsse.jar;C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\jce.jar;C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\lib\charsets.jar;C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\classes;C:\PROGRA~1\JAVA\J2RE14~1.2_0\lib\plugin.jar
sun.boot.library.path = C:\PROGRAM FILES\JAVA\J2RE1.4.2_01\bin
sun.cpu.endian = little
sun.cpu.isalist = pentium i486 i386
sun.io.unicode.encoding = UnicodeLittle
sun.java2d.fontpath =
sun.net.client.defaultConnectTimeout = 120000
sun.os.patch.level =
trustProxy = true
user.country = US
user.dir = C:\WINDOWS\Desktop
user.home = C:\WINDOWS
user.language = en
user.name = Michael G. Coucke
user.timezone =
user.variant =
Done.
Dump classloader list ...
codebase=http://kraken.lowell.edu/, key=http://kraken.lowell.edu/,IONJava/classes/ion_16.jar,IONJava/classes/LP.jar, zombie=false, cache=true, refcount=1, info=sun.plugin.ClassLoaderInfo@109de5b
Done.
Dump thread list ...
Group main,ac=11,agc=2,pri=10
main,5,alive
AWT-Windows,6,alive,dameon
AWT-Shutdown,5,alive
Java2D Disposer,10,alive,dameon
AWT-EventQueue-0,6,alive
Group Plugin Thread Group,ac=3,agc=0,pri=10
Main Console Writer,6,alive
AWT-EventQueue-1,6,alive
TimerQueue,5,alive,dameon
Group http://kraken.lowell.edu/-threadGroup,ac=2,agc=0,pri=4
thread applet-LPRemote.class,4,alive
AWT-EventQueue-2,4,alive
Done.
I'm not a Java expert, so this may be more information than you ever wanted to see.
Once again, I hope that you can help. My experience has been that I usually have some obscure option set incorrectly and that causes me great grief.
Thanks fo your help,
Mike Coucke
[email protected]
----- Original Message -----
From: "Jeffrey Hall" <[email protected]>
To: "'Mike Coucke'" <[email protected]>
Sent: Thursday, September 04, 2003 11:48 AM
Subject: RE: Registration with Lowell Education Online
Hi Mike,
Try it now. I think this problem has arisen because Sun just
released a new version of the Plug-in (1.4.2), and when we released the
public beta of LOPARC, only one relevant version (1.4.0) was available
and the LOPARC code was written to look for that by default. I have
just recoded the relevant routines so they should now cause your browser
to simply pick up the latest 1.4 version of the Plug-in you have
installed, whatever it is. I "broke" Java on my machine to replicate
your problem, and the code I inserted today did fix it. Hopefully it
will have the same effect for you. I am running IE 6 and plugin
1.4.2_01 (as accessed via Tools->Sun Java Console).
One broader problem: some (non-LOPARC-specific) users on the Sun
forums have reported the "JRE collision" you are seeing when multiple
versions of the Plug-in are installed on the same machine. So if the
fix I made to our code doesn't work, one option would be to uninstall
all Java components from your computer and do a fresh install of the
latest runtime environment.
Let me know how/if this works. Thanks for the feedback and for your
patience.
Best regards,
Jeff Hall
Lowell Observatory
-----Original Message-----
From: Mike Coucke [mailto:[email protected]]
Sent: Wednesday, September 03, 2003 6:30 PM
To: [email protected]
Subject: Re: Registration with Lowell Education Online
Hello Jeff:
So far, I have been unable to launch a LOPARC session. I repeatedly
get the following error message:
"Exception: java.lang.ClassNotFoundException: LPRemote.class"
My browser is MS Internet Explorer version 6.0.2800.1106 Initially I was
using Java Plug-In version 1.4.1 and received the error message. I went
to the Sun website and downloaded/installed Java Plug-In version 1.4.2
and still get the message.
Before I try to launch LOPARC, I can select Tools->Sun Java Console from
IE's pull down menu to check my Java Plug-In version. When I try to
launch LOPARC, I get the following message:
"Applet(s) in this HTML page requires a version of Java different from
the one the browser is currently using. In order to run the applet(s)
in this HTML page, a new browser session is required, press 'Yes' to
start a new browser session." If I select 'No', I get the following
message: "Java Plug-in detected JRE collission"
If I select 'Yes', a new browser window opens and then I get the first
message above.
Can you help?
Mike Coucke
[email protected]
----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Monday, September 01, 2003 5:30 PM
Subject: Registration with Lowell Education Online
September 1, 2003
Dear Michael Coucke:
Thank you for registering with Lowell Observatory's online education
site. We hope you enjoy using it and visit regularly as we continue to
expand its features and capabilities. This is a one-time welcoming
email.
For your records, your user ID is xxxxx, and your password is #########.
You'll need to supply these each time you log in.
This site gives you access to research-grade equipment including a 16"
telescope, CCD detector, and image processing software. Our online
archive of data is now available 24/7. The telescope will be opening to
our onsite users in May, and on select nights to the Internet at large
in June.
We have designed this site so you don't need a huge monitor or a
supercomputer to use it. All pages are viewable on screens running at
800x600 resolution or higher. To use LOPARC, you'll need a Java-enabled
browser with the Java 1.4 plug-in installed. If you don't have the
plug-in, you'll be prompted to download it the first time you attempt to
connect. This is an admittedly large (9 MB) but one-time-only download.
This site works correctly under Internet Explorer version 5 or higher.
If you use Netscape, you must be running version 6 or higher, and
display or applet behavior anomalies may occur.
If at any time you can't connect to our server, simply try again later.
We do experience several power outages each year, particularly during
Flagstaff's summer thunderstorm season. Our server is fully protected
and backed up, and can be quickly brought back on line, but any active
user sessions will be lost. Thanks for your patience during these
inevitable downtimes.
Your questions, comments, suggestions, and bug reports about this site
are always welcome. On behalf of the LOPARC development team, thanks
for signing up!
Jeffrey Hall
Assistant Research Scientist
Associate Director, Education and Special Programs
Lowell Observatory
Flagstaff, ArizonaHi Mike,
I see this in your logs:
Java(TM) Plug-in: Version 1.4.2_01
Using JRE version 1.4.2_01 Java HotSpot(TM) Client VM
User home directory = C:\WINDOWS
Proxy Configuration: Manual Configuration
Proxy: http=proxy,https=proxy,ftp=proxy,gopher=proxy
Proxy Overrides:
I just helped my Dad set up his computer with a new
cable modem, and had the situation where we couldn't
access any secure Web sites. The cable folks had us
disable the proxy. It looks like the error message is
saying it can't find your proxy server, and the logs
you posted say that you've decided to configure your
proxy manually, rather than using the settings from
IE (which is how mine is set up in the plugin
control panel.)
Could that be the problem?
--Steve
Maybe you are looking for
-
I have a 44 month old macbook Pro. Yesterday, after an update, the screen stopped working. The laptop otherwise boots normally, and I can get into it using ssh. Looking at the kernel log, I can see a message May 1 13:23:51 Macintosh kernel[0]: IG: I
-
I tried moving an album from iPhoto to Pictures, but the entire iPhoto Library moved. I now cannot open iPhoto. How can I get it back?
-
Oracle JDBC Thin Driver for oracle 9.2.0.4
Hi, It would be nice if someone please guide me to the download of Oracle JDBC Thin Driver for oracle 9.2.0.4. Thanks in anticipation
-
Hi Everyone, i have some graphics *.*emf files from Matlab. when i use graphic on MS Word there is no problem it looks like an orginalm forms but when i convert word file to Pdf with Adobe Pdr Writer, add some gray lines on my graphic (pictures are b
-
Cannot bring material cost, labour, overhead to copa
Dear Forum, Why it is saying that cannot bring material cost, labour, overhead to copa? "In all the system COGS clearing account exists.......but for COPA, condition type VPRS is attached to cost element Cost of Goods Sold because you can not bring a