Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  
  I can't build my project  (Read 554 times)
0 Members and 1 Guest are viewing this topic.
Offline RuKeN

Junior Newbie


Medals: 1



« Posted 2012-11-09 14:51:24 »

The project, run perfectly, but when i clean & build my project, compiler print this notes:

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


And when i run the .jar file, this method return error(when run in IDE, not appear this error):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
@Override //Override from ImageObserver implements
   protected Object loadResource(URL url) {
        try {
            return ImageIO.read(url);
        }
        catch(Exception e) {
            System.out.println("No se pudo cargar la imagen " + url + "\n"
                    + e.getClass().getName()+" "+e.getMessage());
           
            System.exit(0);
           
            return null;
        }
    }


What's my problem/error?
Offline moogie

JGO Knight


Medals: 12
Projects: 6
Exp: 10 years


Java games rock!


« Reply #1 - Posted 2012-11-09 21:16:02 »

difficult to say exactly with the information provided, however the most likely issue it that your images are not accessible.

reasons for this:

1. you have images as files outside of your jar and your runtime path is not what you expect.
2. you have images within your jar but you are loading them using file urls.
3. you have not included the images in your jar but expect them to be
4. your urls are not correct... try starting the url with a slash... i.e. /images/image001.png instead of images/image001.png

Offline RuKeN

Junior Newbie


Medals: 1



« Reply #2 - Posted 2012-11-10 01:41:28 »

Thats the code in ResourceCache class:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
protected Object getResource(String name) {
        Object res = resources.get(name);
       
        if(res == null) {
            res = loadResource("./resource/"+ name);
            resources.put(name, res);
        }

protected Object loadResource(String name) {
        URL url;
        url = getClass().getClassLoader().getResource(name);
        return loadResource(url);
    }


and this the override in SpriteResource class:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
@Override
    protected Object loadResource(URL url) {
        try {
            return ImageIO.read(url);
        }
        catch(Exception e) {
            System.out.println("No se pudo cargar la imagen de "+url);
            System.out.println("El error fue : "+e.getClass().getName()+" "+e.getMessage());
           
            System.exit(0);
           
            return null;
        }
    }


The images are in .../Invaders/src/resource/ and when i build the project, i have a copy of resource into dist folder

I have diferents test, put the full path of the directory, put wihtout ./ or wihtout .

but nothing, dont work the distribuible -.-"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #3 - Posted 2012-11-11 13:08:48 »

Where is the resource folder located in the jar file? Where is the class that is loading the image? The path you have set for resource is a relative path from the level of the class that is trying to load it. Try using absolute path from the root of your source package.

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2012-11-12 13:44:22 »

Check your capitalization in your file names. The IDE lets you get away with it, but in a jar it will crash.

I've had that problem in the past Tongue.

However, if that isn't the problem, can you give us the actual exception? As far as I can tell you have only shown us the code that throws the exception.
Offline RuKeN

Junior Newbie


Medals: 1



« Reply #5 - Posted 2012-11-12 14:45:35 »

Thanks all for help me, i finally can build my project!!!!!!

the problem was, with "/", when i indicate the localization of images, but now work perfectly and this the result:

http://www.mediafire.com/?x9my8gomy2eear1

The application is not finished, just a test application







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.

CopyableCougar4 (9 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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!