Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Where to go next?
Index -> Programming, Java -> Java Help
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Spartan_117




PostPosted: Mon Aug 01, 2005 9:27 pm   Post subject: (No subject)

ya the music is being played through the applet, so the applet must be loading. I hav an attachement which is the screenshot of what i get when opening the applet in the IE Browser. In Firefox the applet just stays grey.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Mon Aug 01, 2005 9:51 pm   Post subject: (No subject)

THat used to always happen to me. Make sure you have ALL the files, and that you have them pointing to an archive or whatever you are holding all your files in. Also, make sure you have the proper version of JRE installed for your browser. If you want, show us the html file with your applet.
Hikaru79




PostPosted: Tue Aug 02, 2005 12:03 am   Post subject: (No subject)

Right-click on the dead applet, click on "Open Java Console" and paste whats in there. That should help us solve your problem Smile
Spartan_117




PostPosted: Tue Aug 02, 2005 12:36 pm   Post subject: (No subject)

This is what it says in Java Console:

Java Plug-in 1.5.0_04
Using JRE version 1.5.0_04 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\seguin4


----------------------------------------------------
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 and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

java.security.AccessControlException: access denied (java.io.FilePermission turtle1.gif read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
at sun.awt.SunToolkit.getImage(Unknown Source)
at BadGuy.<init>(BadGuy.java:53)
at MarioBros.init(MarioBros.java:86)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-MarioBros.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Does anyone understand thiS???

I'll also upload the applet with all the files soon so u guys can take a look at that too.
rizzix




PostPosted: Tue Aug 02, 2005 1:56 pm   Post subject: (No subject)

yea... apparently you are trying to access a file from the client's computer.. this is not allowed.. you can only access stuff from the server it self.
Hikaru79




PostPosted: Tue Aug 02, 2005 2:54 pm   Post subject: (No subject)

Rizzix is right, and I'm sure you can very easily see why you cannot access files on a client's computer through an applet that is automatically downloaded and executed on a remote computer. Java would be a script kiddie paradise if this were possible Very Happy

Here's an FAQ that addresses the security limitations placed on Applets: http://javaboutique.internet.com/community/faq/faq4.html

Oh, and learn to read stack traces, they are VERY useful for debugging. For example, you have not provided any source code, and yet I can tell you this: On line 35 of your file named BadGuy.java (which was called by a constructor of the MarioBros class on line 86), you try to load an image, turtle1.gif . I haven't even seen the source, but I could thoroughly debug it just from the stack trace. So try reading and understanding them whenever you get one Smile It'll make your life easier in the long run.
Spartan_117




PostPosted: Tue Aug 02, 2005 4:15 pm   Post subject: (No subject)

Hikaru are u using some kind of witchcraft? lol jk Laughing

Quote:
yea... apparently you are trying to access a file from the client's computer.. this is not allowed.. you can only access stuff from the server it self.


What do u mean by client's computer? All the files are in the same folder (pictures, class folder, html file, source code), in my account on Windows XP.

I dont exactly understand what this means. And if u guys still want i can post this applet up if u guys need to check.
[Gandalf]




PostPosted: Tue Aug 02, 2005 4:55 pm   Post subject: (No subject)

You should archive all the files you need for the project (include .class files) except for the main class file. Then upload both. Then, when you make your html file for the applet it should look somethign like this:

code:
<applet code=Mario.class archive=Mario.zip width=500 height=300>
 </applet>
Sponsor
Sponsor
Sponsor
sponsor
Spartan_117




PostPosted: Wed Aug 03, 2005 9:39 am   Post subject: (No subject)

Quote:
You should archive all the files you need for the project (include .class files) except for the main class file. Then upload both. Then, when you make your html file for the applet it should look somethign like this:

Code:
<applet code=Mario.class archive=Mario.zip width=500 height=300>
</applet>


Maybe im stupid, but i think im misunderstanding you. This is what i did. I put all the files (every single file needed) in one folder and zipped the folder. Then i copied the original (unarchived) main class file(MarioBros.class) into the same directory as the zipped folder. Then in that same directory i made an HTML file with this code:

code:
<html>
  <head>
    <title>
       The MarioBros applet
    </title>
  </head>
  <body>
    <h2>
      Here is the MarioBros applet
    </h2>
    <hr>
    <applet code="MarioBros.class" archive="TheMarioGame.zip"width="399" height="300">
    </applet>
    <hr>
  </body>
</html>


Is this what im supposed to do? cuz i still get a very long list of errors and the applet still doesnt load.
rizzix




PostPosted: Wed Aug 03, 2005 10:46 am   Post subject: (No subject)

And, refer to the image file in your code by its "name" only . Do not use the entire c:\Docuements and.. bla path.
Spartan_117




PostPosted: Wed Aug 03, 2005 1:52 pm   Post subject: (No subject)

Quote:
And, refer to the image file in your code by its "name" only . Do not use the entire c:\Docuements and.. bla path.


no im already referring it by name (eg. "turtle1.gif")

But i think i'm misunderstanding what Gandalf was trying to tell me:

Quote:

You should archive all the files you need for the project (include .class files) except for the main class file. Then upload both. Then, when you make your html file for the applet it should look somethign like this:

Code:
<applet code=Mario.class archive=Mario.zip width=500 height=300>
</applet>
[Gandalf]




PostPosted: Wed Aug 03, 2005 2:37 pm   Post subject: (No subject)

I don't know, it seems like you are doing it correctly...

Without more experience I can't tell you much more, but I know there is a pretty simple solution.

Here's my last little bit of input (watch this work heh):
*In the applet html code (what I showed you) try taking out the "" quotes. It's the only difference I can see, and I know that my applet works.

So, instead, use this code:
HTML:
<html>
  <head>
    <title>
       The MarioBros applet
    </title>
  </head>
  <body>
    <h2>
      Here is the MarioBros applet
    </h2>
    <hr>
    <applet code=MarioBros.class archive=TheMarioGame.zip width=399 height=300>
    </applet>
    <hr>
  </body>
</html>

Exactly that.
Hikaru79




PostPosted: Wed Aug 03, 2005 5:36 pm   Post subject: (No subject)

Spartan_117 wrote:
What do u mean by client's computer? All the files are in the same folder (pictures, class folder, html file, source code), in my account on Windows XP.

I dont exactly understand what this means. And if u guys still want i can post this applet up if u guys need to check.

Okay, in a network (like the internet), the most common type of relationship is called "Server-Client", and it consists of one computer that serves web pages/applets/files/etc, (called the server), and one of them that recieves what the server is sending (this is called the client). So the computer hosting the applet is a server, and the computer running the applet (viewing it) is called the client. In your case, I assume you are running both from the same computer, so it is both a server and a client. Depending on how the Applet security measures are implemented, this may be the problem -- Java only lets you access the server, not the client, but since you are both, it may choose to not let you access anything. However, the more likely cause of this is that you are keeping the files spread out in the same directory. On a server, this won't work. You need to archive them all together, in a .jar for example, and write a proper Manifest file for it. Then, do as Gandalf instructed, and specify where the archive is in the HTML code. If this doesn't solve anything, then do this again, but upload them to a remote server instead. Unless there are other errors in your code as well, I am 95% confident that this will solve your problem.
Spartan_117




PostPosted: Thu Aug 04, 2005 11:43 am   Post subject: (No subject)

well this is what i did. I archived all the images and music files in a folder and uploaded to my server (geocities.com). Then i took all the classes (MarioBros.class, BadGuy.class, GoodGuy.class) and put them in the same directory as the archive folder with all the images (im using .zip). THen i create an HTML document with the same code Gandalf stated. It seems like its working cuz im getting no errors. But it never loads. It says its loading but it never finishes. It seems its take years to load! Try it yourself: http://www.geocities.com/deville_75/MarioBros.html
Could it be my code?

Image Arena = getImage(getDocumentBase(), "Arena.jpg")

whats the difference between getCodeBase and getDocumentBase?
rizzix




PostPosted: Thu Aug 04, 2005 1:31 pm   Post subject: (No subject)

post us ur code.. all of itt,, the entire folder.. just archive it and post it..
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 45 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: