Results 1 to 5 of 5
Thread: From jar 2 framework
- 06-09-2010, 11:45 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
From jar 2 framework
Hello people,
At this moment we are building a framework that loads games, we load these games with *.jar files. We have it all working except one thing and that is using commands from out the framework, so what have have is this:
Loading jar files: (framework)
What we wanna do now is using a function inside the framework, the function is fired inside the jar file.. The class inside the jar file doesn't know the function in the framework, so how can we manage to get it work?Java Code:public loadJars(File file, boolean isCPU){ String url = file.toURI().toString().substring(6); JarClassLoader loader = new JarClassLoader(url); Class Mainclass = null; try { Mainclass = loader.loadClass("Main"); } catch (ClassNotFoundException e) { e.printStackTrace(); } Object Mainobject = null; try { Mainobject = Mainclass.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } if(Mainobject instanceof MainFrame){ Main = (MainFrame) Mainobject; } Framework.subscribeGame(Main.getGameName()); Framework_GUI.playerFound(); Main.setup(isCPU, Framework.getColor(), this); if(Main.getColor()){ playerturn = true; } else { playerturn = false; } }
Thanks in advanceLast edited by njitram; 06-09-2010 at 11:50 AM.
- 06-09-2010, 03:46 PM #2
What do you mean by "framework"?class inside the jar file doesn't know the function in the framework
How does a jar know anything? A jar is a file structure that holds other files, like .class files.
Do you get errors? If so , please copy and paste full text of messages here.
- 06-09-2010, 04:23 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-09-2010, 06:54 PM #4
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
hmm, we have a some sort of emulator thats what we are calling a framework.
Inside this framework you can open games, these games are classes inside a jar file.
But for external play we must make a connection, so the framework has some function for connecting with the server, but the game has to communicate with the functions inside the framework and that part doesn't work. We can communicate from the framework 2 the jar file, it makes a GUI etc. so that part works fine, only not the other way arround.
What i do have tried now.. is making a function setObject inside the game, so might use the functions inside the framework.
Main.setLoadJars( this ); //Object obj
Then im trying to cast the Object inside the right class but it gives a exception:
java.lang.ClassCastException: Framework.GameEnviroment cannot be cast to GameFramework.GameEnviroment
- 06-09-2010, 10:06 PM #5
games are classes inside a jar fileDoes the game have a method that you can pass the address of/reference to the "framework" to.the game has to communicate with the functions inside the framework
Then the game can use that to call methods in the "framework"
What is the relationship between the two packages? Can they be changed to be the same package?java.lang.ClassCastException: Framework.GameEnviroment cannot be cast to GameFramework.GameEnviroment
Similar Threads
-
what is mean by java Framework?
By makpandian in forum New To JavaReplies: 4Last Post: 03-13-2009, 08:41 AM -
NIO Framework 1.0
By Java Tip in forum Java SoftwareReplies: 0Last Post: 08-20-2008, 02:28 PM -
Echo2 Web Framework 2.1.0.rc4
By Java Tip in forum Java SoftwareReplies: 0Last Post: 04-12-2008, 05:16 PM -
NIO Framework 0.9.3
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-31-2007, 05:29 PM -
Aranea framework 1.1-M4
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-02-2007, 04:07 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks