Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (778)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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  
  How to properly distribute a LWJGL application without JarSplice [SOLVED]  (Read 7153 times)
0 Members and 1 Guest are viewing this topic.
Offline JJengineering
« Posted 2014-12-24 16:28:26 »

Hello dear JGO :)

I want to know how to export/distribute my LWJGL game by hand, without a tool (apart from Eclipse :P),
so that i dont rely on the 'magic' of JarSplice. I want to be able to structure my games/LWJGL application the way i want, with a proper 'folder hierarchy', and make sure it runs properly on every Platform compatible, in a controlled manner. (Folder structure; versioning; resources etc.)
I need control over this process :>

I can't figure out where to start this kind of stuff.

Thank you very much in advance,

greetings and all the best, JJ
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 287
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #1 - Posted 2014-12-24 16:41:03 »

I'm not really sure what you're asking. What specific problem are you having? But I'll try to give you more details:

The most difficult part about LWJGL deployment is that it requires native libraries. These native libraries give LWJGL access to your hardware, such as your graphics card, for OpenGL. That's what makes it so awesome.

The problem is that you have to tell Java where those native libraries are located. You *can* do this as a command line argument, but no users want to run games via the command line.

Tools like JarSplice do that for you: they wrap your LWJGL program in another program that tells Java where the native libraries are located, then runs your LWJGL program. There really isn't a lot of "magic" involved.

I've written an open-source program similar to JarSplice (but with other features for Processing developers) called JarMatey available here: http://staticvoidgames.com/tutorials/deployment/lwjglExample

You could also use something like JWrapper to create a packaged executable, but the idea is the same.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline JJengineering
« Reply #2 - Posted 2014-12-24 18:07:00 »

But i though that the application only has to know about the natives delivered with LWJGL in the natives folder?
To reformulate my 'question', what do i have to learn, to understand the process of exporting and 'hook up' the needed references (LWJGL jars/) and natives,
in order to have the game running on a certain OS. (Either in EXE/DMG etc.)

Furthermore, do you see any advantage of putting the natives (Windows/Linux/OSX) together in one app? I though i was better of including the right natives for a certain 'port'.
To put it this way, i guess i 'want' to know how your program(and JarSplice) put these projects together.
Also with JarSplice etc. i dont know how to order folders in any way... which is a real problem for me!
I do NOT, like the fact that a little program puts my project together, and if it works, it just works..., i prefer knowing whats up :)

Edit: Nice website, a lot of info on there :)

I hope i explained it a tad better this time.
Thank you very much for answering so quick!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 287
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #3 - Posted 2014-12-24 19:27:22 »

But i though that the application only has to know about the natives delivered with LWJGL in the natives folder?

I'm still not totally sure what that means. If your application uses native libraries, you have to tell Java about the natives for your system- how are you running your program on your machine? If you're running it from eclipse, you have to tell it about the natives by attaching the native library to the jar. If you're running from the command line, you have to set -Djava.library.path command line option.

The user of your game has to do the same thing- but that can be pretty annoying for an end-user. That's why we use a wrapper like JarSplice or JarMatey to do it for them.

To reformulate my 'question', what do i have to learn, to understand the process of exporting and 'hook up' the needed references (LWJGL jars/) and natives,
in order to have the game running on a certain OS. (Either in EXE/DMG etc.)

First: understand the above, the java.library.path stuff. Try running a LWJGL application via the command line.

Second: Putting together a platform-specific executable can be pretty annoying. If that's really the route you want to go, you'd have to google "how to create a Windows executable", "how to create a mac app", "how to create a runnable file on linux", etc. I don't think it's very complicated, it's just annoying to have to handle yourself.

Furthermore, do you see any advantage of putting the natives (Windows/Linux/OSX) together in one app? I though i was better of including the right natives for a certain 'port'.

I'd personally put them all in one self-extracting jar using JarMatey. The benefit to this is that I only need to worry about sending people one file- no worrying about making sure I give them the right version. The only downside is that the download size might be a little bigger, but that's really not a concern to most people.

To put it this way, i guess i 'want' to know how your program(and JarSplice) put these projects together.

All of my source is available on GitHub: https://github.com/KevinWorkman/JarMatey

But basically, all I'm really doing is detecting what type of system we're running on, extracting the correct natives, then running the application with the -Djava.library.path set using a ProcessBuilder.

Also with JarSplice etc. i dont know how to order folders in any way... which is a real problem for me!

I'm not really sure what that means either. Why do you need to order the folders?

I do NOT, like the fact that a little program puts my project together, and if it works, it just works..., i prefer knowing whats up Smiley

That's understandable. If you want to dive into my code a little deeper, the "meat and potatoes" of what I'm doing is here: https://github.com/KevinWorkman/JarMatey/blob/master/src/com/staticvoidgames/jarmatey/JarMateyLauncher.java

That's the "launcher" class that runs when the exported jar is run on the user's computer. It extracts the correct natives and then runs the real program after setting the native library path. That's what JarSplice is doing too.

Also, it's worth noting that JOGL and libGDX both have these kinds of "self-extracting" mechanisms in place.

Edit: Nice website, a lot of info on there Smiley

Thanks!

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline orange451

JGO Kernel


Medals: 457
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #4 - Posted 2014-12-24 19:55:22 »

If you don't want to use a third party application.
1  
System.setProperty("org.lwjgl.librarypath", new File("natives").getAbsolutePath());

And have all the library files in a folder called natives Smiley
When you export to a jar, the folder should be in the jar's directory. If you run in eclipse, the folder should be outside of the SRC folder, but still in the project folder.

First Recon. A java made online first person shooter!
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 287
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #5 - Posted 2014-12-24 19:59:19 »

The problem with that approach is that your user then needs to keep the natives directory next to the jar.

The wrapper applications we've been talking about keep the files inside the jar and then extract them to a temporary directory when the jar runs.

It all depends on your context and who your users are. It's usually a good idea to assume most users are lazy and computer illiterate though, haha.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline orange451

JGO Kernel


Medals: 457
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #6 - Posted 2014-12-24 20:03:20 »

Almost every game with libraries ever has them in a folder next to the application; There is no "problem" with it :x.

As long as you package your game in a folder, the user wont get confused.

First Recon. A java made online first person shooter!
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 287
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #7 - Posted 2014-12-24 20:20:07 »

Almost every game with libraries ever has them in a folder next to the application; There is no "problem" with it :x.

I'm not trying to argue, but I've never seen that. Then again, most "real" games are bundled up as a platform-specific executable, not as a jar.

Your approach will certainly work. It just depends on how simple you want to make it for the users. Easier for you = harder for the users. Easier for the users = harder for you. It's a trade-off. I generally go the "hard for me, easy for users" approach, but your way certainly works too.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline orange451

JGO Kernel


Medals: 457
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #8 - Posted 2014-12-24 20:54:26 »

I'm not trying to argue, but I've never seen that. Then again, most "real" games are bundled up as a platform-specific executable, not as a jar.
You've never seen games package libraries outside of the executable?






Had I been on my desktop I would have shown you more examples.

Your approach will certainly work. It just depends on how simple you want to make it for the users. Easier for you = harder for the users. Easier for the users = harder for you. It's a trade-off. I generally go the "hard for me, easy for users" approach, but your way certainly works too.
I'm pretty sure the standard isn't hard for users... Seeing as I gave you games dating from 14 years ago, and I haven't seen anyone complain.


You say you don't want to argue, but right when I open on another possibility that isn't your own you try to shoot it down. JJ clearly said:
Quote
I want to know how to export/distribute my LWJGL game by hand, without a tool
I gave him exactly that.

First Recon. A java made online first person shooter!
Offline JJengineering
« Reply #9 - Posted 2014-12-24 21:35:48 »

Hey guys, thank you so much for the answers :)

I can see that my urge to 'do it all by myself', will turn into something i'll most probably break first, before actually beeing able to use it properly, especially now where i want to finish my game.

I guess, for now i start to learn the java path stuff when i've got time, and eventually when i have time do some work on the rest, try out your suggestions :)
It seems to be nothing complicated, but having to delve into a new topic again, is not acceptable i think, after all. (Atm, i have to learn all sorts of stuff to finally get some stuff going like savegames etc. which turns out to be a huge pain to get going with a large, complex amount of data).

Quote from KevinWorkman:
Quote
I'm not really sure what that means either. Why do you need to order the folders?

Well i wanted to structure my final game the way i wanted because:
* 'more' beautiful  ;D (programmer urge i guess)
* i'd like to have an idea how things change over time, and i dont know how the program is putting it together

Just having an executable and a resource folder doesn't quite cut it for me, i guess you can understand that i want a little more control of that:
I dont just dump all of my classes in my 'src' package either .... :)



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #10 - Posted 2014-12-25 03:28:57 »

I too had faced this problem once, but I went on and implemented a
NativesLoader
class. This class will extract the native libraries packaged inside the JAR to a temporary directory, sets the
java.library.path
property to the temporary directory where I extracted the natives. Finally in the end, I delete the natives and the temporary directory that I created before quitting the game.

Offline KevinWorkman

« JGO Plugged Duke »


Medals: 287
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #11 - Posted 2014-12-26 17:03:34 »

You've never seen games package libraries outside of the executable?

Again, I really don't want to bicker- but the examples you've shown are of *installation directories*, which is an option I already brought up, using JWrapper.

What I *don't* see is a game that consists of a single executable (not installable) file that requires a data directory next to that executable. That's too easy for users to mess up, so even though it would be easy for a developer to implement, it's not something that many "real" games do.

The examples you've shown of an installation directory aren't really what I'm talking about. That's certainly another option, but it involves using something like JWrapper to create an installer.

Sorry if I should have been more clear, but I think we're talking about two different things at this point.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 287
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #12 - Posted 2014-12-26 17:13:04 »

I guess, for now i start to learn the java path stuff when i've got time, and eventually when i have time do some work on the rest, try out your suggestions Smiley

Yeah, exactly. Step on is understanding what the java.library.path argument is doing. Any other solutions are going to set this argument somehow, so it's the most basic building block of any more complicated solution, even one you write yourself.

Well i wanted to structure my final game the way i wanted

That's understandable. I don't really remember how JarSplice organizes its natives, but I can tell you how JarMatey organizes its natives:

First, the output jar contains a directory called JarMateyNatives.
Inside that directory, you can put directories for any OS you want to include natives for: Windows, Mac, Linux, for example.
Then inside those directories, you can put native files for those specific operating systems. You'd put dll files in your Windows directory, etc.
You can also put subdirectories for specific architectures inside the OS directories: Windows/amd64, for example.
Then inside those subdirectories, you can put native files for those specific OS/architecture combos.

When JarMatey runs, it detects what kind of system it's on, then extracts the native files from the corresponding directories. They are extracted to a temporary directory, and the java.library.path is set to that temp directory. Then when the program closes, that temporary directory is deleted.

You can also include external resource files in JarMatey if you want, and the process is pretty much the same: JarMatey extracts these files to a temporary directory, then sets the "current directory" to that directory, so any code you write can assume those files or folders are next to the jar.

You can use whatever organization you want for the external files.

Anyway, I'm not trying to "sell you" on JarMatey, just using it as an example for how things might work.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline JJengineering
« Reply #13 - Posted 2014-12-28 12:59:48 »

Thank you very much again, i'll look into all the java stuff, and then i'll get working on my own solution.
Game programing is a never ending hole it seems :P


Quote
Quote by KevinWorkman:
Anyway, I'm not trying to "sell you" on JarMatey, just using it as an example for how things might work.
You made me understand, how these tools work, and that's something i really appreciate, since for me it really was 'magic' :)
Your tool is definitely a source to learn from, so thank you very much for posting it :P

Greetings and all the best, JJ
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (377 views)
2018-11-16 13:46:03

hadezbladez (198 views)
2018-11-16 13:41:33

hadezbladez (379 views)
2018-11-16 13:35:35

hadezbladez (93 views)
2018-11-16 13:32:03

EgonOlsen (2195 views)
2018-06-10 19:43:48

EgonOlsen (2235 views)
2018-06-10 19:43:44

EgonOlsen (1387 views)
2018-06-10 19:43:20

DesertCoockie (2025 views)
2018-05-13 18:23:11

nelsongames (1691 views)
2018-04-24 18:15:36

nelsongames (2323 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!