Hello,

I am trying to create a update section of a game but running into a problem of JFrames.

What I want to do is have a single JFrame that will have the update script, then after the update it will start a jar file in the JFrame (With the applied updates).

Is there a way to set the contents of a JFrame to a jar file?

An example of this is (i think) a game called Minecraft (By Notch) where you launch the application, you login and it updates (if needed). After all of that the minecraft.jar file (the one downloaded by the update script) is started in the JFrame without closing it.


Any and all help is appreciated.

-- Turt2Live

Is there a way to set the contents of a JFrame to a jar file?

A jar file contains files. Just about any type of file can put put in a jar file.
In that context, what do you mean by the above?

By putting the jar file on the classpath when running your program, you can call/use any classes that are in the jar file. For example if there were a class that extended JPanel, you could add that to your JFrame.

So a jar file is just like a zip file (theoretically)?

If the classpath includes the jar file, then would I call the class as normal?
eg: JarClass jar = new JarClass();

or something else?

As well, would the jar need to be executable?

Thanks for your help.

Yes the jar file is like a zip file.
yes, if the JarClass class is in the jar file, that new statement should work, if you have the package name correct.

Not sure what "need to be executable" means in this context. For the above usage, it would not need to be executable.

By executable I assume you mean:
java -jar JarFileName.jar
would start a program from within the jar file.

Edited 5 Years Ago by NormR1: n/a

Yes, thats what I meant.

One last question, in Eclipse, how would you add that second jar (JarClass) to the class path? How would that change if the jar can be placed anywhere in the computer (As I have it setup right now it will dump all required files to a directory in the same directory the program was started in, so the jar could be in C:\Users\Me\MyProgram or C:\MyProgram although the jar file will always be in the directory "files" so C:\MyProgram\files\MyJar.jar or C:\Users\Me\MyProgram\files\MyJar.jar)?

This question has already been answered. Start a new discussion instead.