Page 1 of 3 123 LastLast
Results 1 to 20 of 45
Like Tree3Likes

Thread: My game isn't working

  1. #1
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Exclamation My game isn't working

    Hi, gentlemen i got a problem, i really don't know what's going on, in the eclipse there are no problems but when i play the game as a runnable jar file, the game stops working.

    I used AWT,SWING and Applet in this program.

    If someone knows what's happenin', please tell me.

    https://ufile.io/e7f17

    My game isn't working-dasfas.jpg

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    Any errors?
    DO you produce any logs?
    If not you might want to look into that.

    Have you run it from the command line?
    java -jar your-jar-file
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    If you want to look inside the code, i'll be happy to share with you.

    There are no logs, the game just stops working, i have no idea why..

    https://ufile.io/84c22

  4. #4
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Someone send me this image about the error, but i went to the code i didn't figure out what's it! =/

    My game isn't working-8c81a7f3df314165b19f706e31cec04a27d1c529.png

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,995
    Rep Power
    32

    Default Re: My game isn't working

    The console image(text would allow parts to be copied) shows a NPE. Look at the line where the error happened and find the null value.

    Please copy the text next time, not an image.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    Looks like an image issue.
    How are you loading images?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    There are no null value(i didn't find it),that's the problem. And the .jar file is running in my pc but not working in another one.

  8. #8
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Line 29 error:

    import java.awt.Image;
    import java.awt.Rectangle;

    import javax.swing.ImageIcon;

    public class Enimes extends Caracteristica{
    static int cont = 0;
    public Enimes(int x, int y){
    this.x = x;
    this.y = y;

    ImageIcon refEnemy;
    if(cont++ % 3 == 0){
    refEnemy = new ImageIcon(getClass().getResource("Asteroid.png"));
    }

    else if(cont++ % 2 == 0){
    refEnemy = new ImageIcon(getClass().getResource("asteroid2.png")) ;
    }

    else if(cont++ % 4 == 0){
    refEnemy = new ImageIcon(getClass().getResource("asteroid2s.png") );

    }

    else{
    refEnemy = new ImageIcon(getClass().getResource("Rock_Asteroid.pn g"));
    }
    img = refEnemy.getImage();

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    What line is line 29 in the Inimigos class?
    That's where the ImageIcon is being created that is throwing the null pointer exception.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    Yes it is, i just translate the name to facilitate the understanding.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    It's called by the actionPerformed method of the Tela class, line 81 of that one.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    OK, so which is line 29?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  13. #13
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    This one:
    refEnemy = new ImageIcon(getClass().getResource("Rock_Asteroid.pn g"));

  14. #14
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    else{
    refEnemy = new ImageIcon(getClass().getResource("Rock_Asteroid.pn g"));
    }
    img = refEnemy.getImage();

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    OK, and where in the jar file is the Rock_Asteroid.png?

    Also, can you use code tags? Like the 'quote' tags, but with 'code' written instead.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  16. #16
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    That image is inside the code, i mean, is inside a folder, all images too.

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: My game isn't working

    But where?
    What is the structure of the jar file?

    I'm guessing that the image isn't actually in the jar file, or has ended up in the wrong place.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  18. #18
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: My game isn't working

    It might be easier to import the code into an IDE, ensure it works, and repackage it as a jar.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  19. #19
    sancho is offline Member
    Join Date
    Apr 2016
    Posts
    25
    Rep Power
    0

    Default Re: My game isn't working

    I'm a novice programmer, this is my first game sorry if i didn't give better explanations,
    i exported the game as a runnable jar with the libraries extracted into generated jar.

    I used the eclipse neon IDE
    Last edited by sancho; 11-23-2016 at 05:41 PM.

  20. #20
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,995
    Rep Power
    32

    Default Re: My game isn't working

    Can you look in the jar file to see what is there and where it is located?
    Open the jar file with a zip utility program - rename the jar file by adding the extension: .zip will make it easier.
    If you don't understand my response, don't ignore it, ask a question.

Page 1 of 3 123 LastLast

Similar Threads

  1. Tic Tac Toe game - winning logic not working.
    By Mikki in forum New To Java
    Replies: 21
    Last Post: 11-05-2012, 08:51 PM
  2. working on a pacman game need help
    By paris72 in forum Java Gaming
    Replies: 2
    Last Post: 06-04-2012, 10:04 AM
  3. Game using swings not working
    By humanbeing in forum Java Gaming
    Replies: 7
    Last Post: 10-06-2010, 03:04 PM
  4. Game Help.working on it for days,.
    By xSkittlesx in forum Java Applets
    Replies: 12
    Last Post: 05-31-2010, 03:24 PM
  5. Gueesing Game Almost done, but not working correctly
    By mbnumba6 in forum New To Java
    Replies: 5
    Last Post: 03-18-2009, 03:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •