Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Appletviewer vs. web browser.  (Read 1801 times)
0 Members and 1 Guest are viewing this topic.
Offline Manfred

Senior Newbie




Java games rock!


« Posted 2004-10-28 17:46:03 »

My code is loading up and running in applet viewer, but not in a web browser.

It is far too big a game to post here, but I'm guessing the problem would be in how the images/files are loaded.  Is that the first place to look when debugging this problem?
Offline Manfred

Senior Newbie




Java games rock!


« Reply #1 - Posted 2004-10-28 17:57:57 »

I'm not having a problem loading other applets into the browswer either.

Maybe because I'm using ImageIcon to load the images improperly?

           ImageIcon pausedIcon = new ImageIcon("res/pause.png");
           pausedImage = pausedIcon.getImage();
Offline Manfred

Senior Newbie




Java games rock!


« Reply #2 - Posted 2004-10-28 17:59:23 »

Only other files I'm loading I do like so:

                 String s = new String(applet.getCodeBase().getPath() + animFile);
                 System.out.println(s);
                 File file = new File(s);
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Manfred

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-10-28 21:08:32 »

I was correct about the image/file problem.

My solution, in the end, was to use getImage(getCodeBase(), "myfile.png");
then create ImageIcon with the image to make sure it loaded completely before going on.


It works under Firfox.  It does not work under IE.  I assume it is a JVM/security problem.  I'm running XP.  Anyone have any ideas?

Offline erikd

JGO Ninja


Medals: 15
Projects: 4
Exp: 14 years


Maximumisness


« Reply #4 - Posted 2004-10-28 22:05:02 »

If none of the games at http://www.home.zonnet.nl/duijs24/jemu/ don't work in IE either, I assume java is not enabled in IE.
If you have java installed, you should see at Internet Options->Advanced a checkbox with 'Java (Sun)' which has to be enabled. If the checkbox is not there, then maybe java is not properly installed (re-installing java should do the trick).
I assume if the applet works on one browser, it should work in another browser as well, provided that they both support java (and not just the MS VM, which is not really java).
If you want to have your code running on the MS VM as well and you don't use any features of java 1.2 and up, you should compile your code with a -target 1.1 option.

I hope this helps,
Erik

Offline Manfred

Senior Newbie




Java games rock!


« Reply #5 - Posted 2004-10-29 00:02:37 »

all the 2d ones work.  The 3D ones do not.  
Offline erikd

JGO Ninja


Medals: 15
Projects: 4
Exp: 14 years


Maximumisness


« Reply #6 - Posted 2004-10-29 09:43:04 »

Could you go to the Control Panel, open 'Java Plug-in' and enable the console? If you try your applet, you will see the output with exceptions etc in the console. You could then copy/paste the console output here.

Erik

Offline Manfred

Senior Newbie




Java games rock!


« Reply #7 - Posted 2004-10-29 13:55:27 »


file:/C:/PROGRA~2/java/upload2/boxman.jar!/res/red.tda
java.security.AccessControlException: access denied (java.io.FilePermission file
:\C:\PROGRA~2\java\upload2\boxman.jar!\res\red.tda read)
       at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:269)
       at java.security.AccessController.checkPermission(AccessController.java:
401)
       at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
       at java.lang.SecurityManager.checkRead(SecurityManager.java:863)
       at java.io.FileInputStream.<init>(FileInputStream.java:100)
       at CharacterAnims.<init>(CharacterAnims.java:74)
       at GameManager.init(GameManager.java:135)
       at sun.applet.AppletPanel.run(AppletPanel.java:353)
       at java.lang.Thread.run(Thread.java:534)






Which should be from this bit of code:



URL url = this.getClass().getResource(animFile);
System.out.println(url.getPath());
String s = new String(url.getPath());//applet.getCodeBase().getPath() + animFile);
File file = new File(s);
fileInputStream = new FileInputStream(file);
objectInputStream = new ObjectInputStream(fileInputStream);

Offline Manfred

Senior Newbie




Java games rock!


« Reply #8 - Posted 2004-10-29 13:57:22 »

Maybe the problem lies in the exclamation point in my path.
Offline tom
« Reply #9 - Posted 2004-10-29 15:34:24 »

You can not read files that is on the local computer from an applet. But you can read files that is provided with the applet using the classloader. You get an InputStream with the following code "getClass().getResourceAsStream(path);"

"path" is relative to the applet, and may look something like "/images/img1.tga".

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Manfred

Senior Newbie




Java games rock!


« Reply #10 - Posted 2004-10-29 15:53:28 »

The jar is on my pc during development.  Hence the C drive.

The function getResourceAsStream() is the thing I was missing.  Thank you .  
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!