Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 5:04 am

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Nov 18, 2006 3:17 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
Hi all !
I try to run some codes but i get that error :
"failed to initialize controllers"
"cause by: noClassDefFoundError: net/java/games/input/ControllerEnvironement"
Here is the code :
Code:
import org.newdawn.slick.*;
import java.awt.*;
public class SlickTests
{
   public static void main (String[] args)
   {
      try
      {
         Game game = new Game();
         MyGameContainer myGameContainer = new MyGameContainer(game);
         AppGameContainer appGameContainer = new AppGameContainer(game, 936, 733, false);
         game.init((GameContainer)myGameContainer);
         Input input = new Input();
         input.initControllers();
         appGameContainer.start();
      }
      catch(Exception e)
      {
         
      }
   }
}

class Game implements org.newdawn.slick.Game
{
   public String getTitle()
   {
      return "";
   }
   public boolean closeRequested()
   {
      return false;
   }
   public void render(org.newdawn.slick.Graphics g)
   {
      
   }
   public void update(GameContainer container, int delta)
   {
      
   }
   public void init(GameContainer container)
   {
      
   }
   public void controllerButtonPressed(int controller, int button)
   {
      
   }
   public void controllerButtonReleased(int controller, int button)
   {
      
   }
   public void controllerDownPressed(int controller)
   {
      
   }
   public void controllerDownReleased(int controller)
   {
      
   }
   public void controllerLeftPressed(int controller)
   {
      
   }
   public void controllerLeftReleased(int controller)
   {
      
   }
   public void controllerRightPressed(int controller)
   {
      
   }
   public void controllerRightReleased(int controller)
   {
      
   }
   public void controllerUpPressed(int controller)
   {
      
   }
   public void controllerUpReleased(int controller)
   {
      
   }
   public void inputEnded()
   {
      
   }
   public boolean isAcceptingInput()
   {
      return false;
   }
   public void keyPressed(int key, char c)
   {
      
   }
   public void keyReleased(int key, char c)
   {
      
   }
   public void mouseMoved(int oldx, int oldy, int newx, int newy)
   {
      
   }
   public void mousePressed(int button, int x, int y)
   {
      
   }
   public void mouseReleased(int button, int x, int y)
   {
      
   }
   public void setInput(Input input)
   {
      
   }
}

class MyGameContainer extends org.newdawn.slick.GameContainer
{
   public MyGameContainer(Game game)
   {
      super(game);
   }
   
   public boolean  hasFocus()
   {
      return true;
   }
   public void  enterOrtho()
   {
      
   }
   public void  enterOrtho(int xsize, int ysize)
   {
      
   }
   public int  getScreenHeight()
   {
      return 1;
   }
   public int  getScreenWidth()
   {
      return 1;
   }
   public void  setIcon(java.lang.String ref)
   {
      
   }
   public void  setMouseGrabbed(boolean grabbed)
   {
      
   }
}

Tx to help me :P


Last edited by orelero on Sat Dec 02, 2006 1:38 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 5:09 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Thats because you don't have JInput.jar in your classpath. However, this is handled for you by Slick if instead of doing:

Code:
Input input = new Input();
input.initControllers();


You do instead:

Code:
input = container.getInput();


If you want controllers to work you need java the JInput jar and native libraries available. When the container initialises, if it can't find them it simply marks that there are no controllers and carries on.

Looking at your code you also shouldn't need MyGameContainer and you'd save yourself alot of effort if you extended BasicGame rather than implementing Game itself - but of course as wth everything Slick - it's your choice :)

Check out some out some of the tests in the source code for examples of how simple the code can be.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 6:20 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
Hi Kevin !

i followed your instructions and changed my code into this :
Code:
import org.newdawn.slick.*;

public class SlickTests
{
   public static org.newdawn.slick.Image icone ;
   public static void main (String[] args)
   {
      try
      {
         MyBasicGame myBasicGame = new MyBasicGame("Tanks");
         AppGameContainer appGameContainer = new AppGameContainer(myBasicGame, 936, 733, false);
         myBasicGame.init((GameContainer)appGameContainer);
         Input input = new Input();
         input = appGameContainer.getInput();
         appGameContainer.start();
      }
      catch(Exception e)
      {
         
      }
   }
}

class MyBasicGame extends org.newdawn.slick.BasicGame
{
   public MyBasicGame (String title)
   {
      super(title);
   }   
   public void init(GameContainer container)
   {
      
   }
   public void render(org.newdawn.slick.Graphics g)
   {
      
   }
   public void update(GameContainer container, int delta)
   {
      
   }
}

I also asked my EDI to place Jinput.jar in the class path and i also put it in the output path of the project, and also put it in the "lib" folder of my jdk and placed all natives libraries in the "bin" folder.
I still get the same error :cry: :cry: .
By the way,what will i need to embed in the jar file of my game ?

Thank you very much !


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 6:36 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Change this:

Code:
Input input = new Input();


to

Code:
Input input;


You don't need to create your own instance of Input - game contrainer creates one for you.

You need to have jinput.jar available at runtime, not compile time - which IDE are you using?

When you want you to distribute the game you can either webstart it with the Slick extnsion (meaning you don't need to embed it at all) or you simply package the jars and natives with what ever packer you're using.

Webstart seems the easiet.. check out this for an example of webstarting your game:

http://slick.cokeandcode.com/index.php? ... 113-033046

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 7:06 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
still doesn't work with that modification :roll: .
I use the jdk5build7 and my EDI is the easy-to-use JCreator V3.5 .


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 7:34 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Ok, compiled and ran locally, you also don't need:

Code:
myBasicGame.init((GameContainer)appGameContainer);


The container does that for you. Your startup should look something like this taken from GraphicsTest.java:

[code]
try {
AppGameContainer container = new AppGameContainer(new GraphicsTest());
container.setDisplayMode(800,600,false);
container.start();
} catch (SlickException e) {
e.printStackTrace();
}
/code]

Note that like this if the controllers jar is missing an exception will still be displayed but the game will start anyway (the exception just lets you know you haven't got the JARs/Natives in place).

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 7:35 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
i tryed to compile and run the puzzle example and i get the same exception :shock:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 7:39 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Um, you get the exception - but it doesn't stop the game running right?

If it does stop it running - could i have the stack trace?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 7:41 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Ah, I think I see, you *do* need jinput.jar in your classpath - but you don't *have* to have the natives in place.

If you're getting a NoClassDefFoundError however this always means you don't have jinput.jar in your classpath at runtime.

EDIT: Or maybe it's a platform specific thing - what OS you running on?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 7:44 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
i run on Windows XP (pro edition, service pack2)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 8:05 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Yeah, same here. Could you give me the full stack trace shown. Also, I've never used JCreator, how do you run things from it?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 8:28 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
here is the stack trace :
Quote:
Sat Nov 18 21:21:40 CET 2006 ERROR:Failed to initialise controllers
org.lwjgl.LWJGLException: Failed to initialise controllers
at org.lwjgl.input.Controllers.create(Controllers.java:61)
at org.newdawn.slick.Input.initControllers(Input.java:488)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:155)
at SlickTests.main(SlickTests.java:15)
Caused by: java.lang.NoClassDefFoundError: net/java/games/input/ControllerEnviro
nment
at org.lwjgl.input.Controllers.create(Controllers.java:38)
... 3 more
Sat Nov 18 21:21:40 CET 2006 INFO:Controllers not available
Sat Nov 18 21:21:40 CET 2006 INFO:LWJGL Version: 1.0beta
Sat Nov 18 21:21:40 CET 2006 INFO:Starting display 936x733
Press any key to continue...


To run my programs on JCreator, i just click on build project then Execute project. I can set up compilation parameters. For usefull details i could ask some things to the JCreator staff because i don't know much about this software :oops: .


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 8:35 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Ok, I'm sorta paraphrasing from JCreator FAQ here but it seems like you don't have the runtime parameters setup (only the compile time) - hence it can't JInput.jar

Select "Runtime Configurations" from the "build" menu
Edit the one you're using to run your tests

I think the settings would be in here - I wish I had JCreator to help out more. In your build properties which JARs do you have? You should have:

slick.jar
lwjgl.jar
jinput.jar
jogg-0.0.7.jar
jorbis-0.0.15.jar
ibxm.jar

To build against Slick - maybe JCreator inherits these settings?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 8:55 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
I'm afraid , on that section i just can modify runtime parameters :-s.
On the "Adding Common Classes and Libraries to Projects" section, it explains how it works under JCreator :
http://www.skylit.com/javamethods-old/f ... ator2.html
Dunno wether it's useful :roll:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 18, 2006 9:19 pm 
Offline
Oldbie

Joined: Sat Nov 18, 2006 3:11 pm
Posts: 254
Location: Helsinki
I could give Eclipse a try since it's free and efficient, but it's far more complex than JCreator.

edit: just found that topic :
http://lwjgl.org/forum/viewtopic.php?t=1300&sid=5cc807fa44c9809780b512a6910b4e2d


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group