Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (113)
games submitted by our members
Games in WIP (563)
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  
  What would cause more than one class file?  (Read 2246 times)
0 Members and 1 Guest are viewing this topic.
Offline Manfred

Senior Newbie




Java games rock!


« Posted 2004-10-28 19:02:20 »

Sorry about all the newbie questions.

I know that if you have two classes in the same file you would get one, but what other case?

I've got my myClass.java, and it produces:
myClass.java
myClass$1.java

What's that all about?
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2004-10-28 19:06:07 »

That'll be inner, anon classes. You've probably got one wrapped around a window closed event. Smiley

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Manfred

Senior Newbie




Java games rock!


« Reply #2 - Posted 2004-10-28 19:10:31 »

Thanks.

Any way to get rid of it?  I want to run the applet from my comcast account, and it won't allow files with a $ in them.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2004-10-28 19:12:38 »

Well you could always move it into a proper, named class in another source file, but thats not very convinient.

I havn't done any applet stuff for ages, but shouldn't you be uploading a jar instead of individual files?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Manfred

Senior Newbie




Java games rock!


« Reply #4 - Posted 2004-10-28 19:14:38 »

Jar eh?  I like the sound of that.  

Been a while since I did anything applet related as well.  I forget these things.

You wouldn't happen to have off hand a link to some info on setting up the jar, would you?


Thanks for your help by the way.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2004-10-28 19:21:08 »

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html

I always forget the usage though... I shove it in a build script and forget about it. Embarrassed

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Manfred

Senior Newbie




Java games rock!


« Reply #6 - Posted 2004-10-28 19:28:43 »

Again, thank you.
Offline woogley
« Reply #7 - Posted 2004-10-28 21:42:00 »

in your case, Manfred, you would do this:

from command-line:
1  
jar cf MyJar.jar myClass*.class


then in your HTML:
1  
<applet archive="MyJar.jar" code="myClass"></applet>
Offline Manfred

Senior Newbie




Java games rock!


« Reply #8 - Posted 2004-10-28 21:58:21 »

Quote
in your case, Manfred, you would do this:

from command-line:
1  
jar cf MyJar.jar myClass*.class


then in your HTML:
1  
<applet archive="MyJar.jar" code="myClass"></applet>

Creating the jar seems to work, but it doesn't work in a browser now.  I'm guessing I have to change the way I load images and files.  
Offline Manfred

Senior Newbie




Java games rock!


« Reply #9 - Posted 2004-10-28 23:14:18 »

Here is what I'm trying in order to load a file:

url = this.getClass().getResource("res/pic.jpg");
tempImage = getImage(url);
ImageIcon frameIcon = new ImageIcon(tempImage);
frame = frameIcon.getImage();

Problem is that if I do this enough times, it craps out.  Memory problem possibly?  Do I have to close some resources down before continuing?  

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

JGO Coder


Medals: 2


pixels! :x


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

> Problem is that if I do this enough times, it craps out

Uhm... load the image once... draw it as often as you like.

edit: confusing stuff removed :>

弾幕 ☆ @mahonnaiseblog
Offline Manfred

Senior Newbie




Java games rock!


« Reply #11 - Posted 2004-10-28 23:27:04 »

Sorry.  Didn't make myself clear.

Loading a bunch of different images.

Using that code over and over, but with different image files.

I probably have 1 meg or so of images to load.
Offline Manfred

Senior Newbie




Java games rock!


« Reply #12 - Posted 2004-10-28 23:34:08 »

What I mean to say is that I have:


url = this.getClass().getResource("res/pic1.jpg");
tempImage = getImage(url);
ImageIcon frameIcon = new ImageIcon(tempImage);
frame = frameIcon.getImage();

url = this.getClass().getResource("res/pic2.jpg");
tempImage = getImage(url);
ImageIcon frameIcon = new ImageIcon(tempImage);
frame = frameIcon.getImage();

url = this.getClass().getResource("res/pic3.jpg");
tempImage = getImage(url);
ImageIcon frameIcon = new ImageIcon(tempImage);
frame = frameIcon.getImage();

url = this.getClass().getResource("res/pic4.jpg");
tempImage = getImage(url);
ImageIcon frameIcon = new ImageIcon(tempImage);
frame = frameIcon.getImage();

{except more pics}

So this doesn't work.  I comment out pic4 block, it works.

I move pic4 block to the top, uncomment all, doesn't work.  Comment out the bottom block, now pic3 block, and it works.  (the last bit was me checking to see if I had a typo in pic4 block, or if it might be some other problem.  Tired eyes.)

 
Offline Manfred

Senior Newbie




Java games rock!


« Reply #13 - Posted 2004-10-28 23:39:26 »

maybe there's a releaseResource, or something like that.
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #14 - Posted 2004-10-28 23:45:33 »

> I probably have 1 meg or so of images to load.

Yea, uhm... one mb of *compressed* image data. It will take up much more ram once it's decompressed. For example a 512x512 image with 3 channels (RGB)...

512*512*3=786432 bytes

So that's already ~0.8mb.

>maybe there's a releaseResource, or something like that.

You can disable ImageIO's caching like so:
ImageIO.getUseCache(); //call it once at the beginning

弾幕 ☆ @mahonnaiseblog
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #15 - Posted 2004-10-29 00:52:45 »

ImageIcon doesn't use imageio to load images, it's just a wrapper around Toolkit.getImage/MediaTracker, so disabling caching won't help.

When are you loading the images? in which appet method, I mean?


Offline Manfred

Senior Newbie




Java games rock!


« Reply #16 - Posted 2004-10-29 11:39:00 »

Quote
ImageIcon doesn't use imageio to load images, it's just a wrapper around Toolkit.getImage/MediaTracker, so disabling caching won't help.

When are you loading the images? in which appet method, I mean?



Init().  I seperated the loads into their own function, called from init, not just to make it cleaner, but to see if java would do some cleanup of memory once the function ended after each call.  No such luck.
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.

Dwinin (16 views)
2014-09-12 09:08:26

Norakomi (50 views)
2014-09-10 13:57:51

TehJavaDev (59 views)
2014-09-10 06:39:09

Tekkerue (27 views)
2014-09-09 02:24:56

mitcheeb (50 views)
2014-09-08 06:06:29

BurntPizza (34 views)
2014-09-07 01:13:42

Longarmx (20 views)
2014-09-07 01:12:14

Longarmx (23 views)
2014-09-07 01:11:22

Longarmx (22 views)
2014-09-07 01:10:19

mitcheeb (31 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!