Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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  
  [Solved] Loading LWJGL natives - (Running a .jar in linux)  (Read 1934 times)
0 Members and 1 Guest are viewing this topic.
Offline MatthewNicholls

Junior Devvie


Medals: 6
Exp: 6 years



« Posted 2013-03-31 21:38:04 »

Hello, I just wondered if anyone could help me with this Clueless. I usually develop on Win 8 but want to make sure my jar files run on Linux also.

I can make a Display using LWJGL and run it on eclipse  and export a .jar to run on windows and everything runs as expected. If I take the same project and run it in eclipse on Linux Mint it runs just the same, but it will not run as a .jar file. (I can even export the jar file in Linux Mint and then run it on Windows)

I have the natives in a folder called "natives"  (for each OS in the same folder) in the same directory as the game.jar.

I use
1  
System.setProperty("org.lwjgl.librarypath",new File("natives").getAbsolutePath());


Or
1  
System.setProperty("org.lwjgl.librarypath",System.getProperty("user.dir") + "/natives/");


to load the natives. I give the permissions to the Jar file to run and use the OpenJDK 7.
Does anyone know what I can do to get it working on both windows and Linux?

Cheers  Wink

my blog
"...Muahahhah.ahahah... pull the lever Egor!" ..."Yesh mashter"..click... click...click..buzzzzz".......Its Alive!"
Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2013-03-31 22:17:02 »

I just fired up a Linux Mint VM and using both ways worked. Are you sure the Linux natives are included?

Offline MatthewNicholls

Junior Devvie


Medals: 6
Exp: 6 years



« Reply #2 - Posted 2013-03-31 23:36:38 »

I just re-downloaded to be sure. But as it works in eclipse in Linux mint I thought that probably couldn't be the problem. Also libGdx works fine as well, which is really confusing.

Well I don't know why it wont work, but for now I just keep coding in Windows and worry about running on linux later, my priority is running on Windows/Android first anyway so I'm not too worried. Clueless

my blog
"...Muahahhah.ahahah... pull the lever Egor!" ..."Yesh mashter"..click... click...click..buzzzzz".......Its Alive!"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2013-04-01 23:21:30 »

Could you send me a test example that doesn't work on Linux?

Offline MatthewNicholls

Junior Devvie


Medals: 6
Exp: 6 years



« Reply #4 - Posted 2013-04-02 20:14:23 »

Ok I sent you the file but in the meantime I found out that I can run it if I open a terminal and type
1  
java -jar Game.jar


 Roll Eyes
I didn't know this is how to open jar files on linux as I'm a complete linux noob. I was expecting to be able to write click and ask to open with the OpenJDK7 as I can for other Jar files.
So the thing is, it does work but I don't think it is really easy to do for beginners(to linux), such as myself and I want my programs to open in a very user friendly way. Is there a way of making a single click file that would open the program for a non developer?


my blog
"...Muahahhah.ahahah... pull the lever Egor!" ..."Yesh mashter"..click... click...click..buzzzzz".......Its Alive!"
Offline matheus23

JGO Kernel


Medals: 114
Projects: 3


You think about my Avatar right now!


« Reply #5 - Posted 2013-04-02 20:54:47 »

Is there a way of making a single click file that would open the program for a non developer?

Two answers here:
1. This answer is only for your own usage. It makes using .jar files easier:
[this guide is for KDE]
  • Right-click on any jar file in the file explorer (dolphin for me)
  • Click on the 'File type options'-button
  • Click 'Add'
  • Type in 'java -jar', Check 'Run in terminal' if you want it to run in terminal... (obviously)
Hope this helps for you, I've seen this techneque fail somehow... Sad

2. How to distribute .jar files, to make them available to other linux users:
  • create a new file named 'run.sh' in the same directory as your .jar file
  • open it with a text editor
  • write this into the file:
1  
2  
#!/bin/bash
java -jar YourJarName.jar

  • close the editor, right-click the file and click 'Properties'. You might search a little on GNome / Unity, but on KDE it's like this: Under the tab 'Permissions' check 'is executable'

If you now double-click the .sh file, the jar starts.

I'm sorry. There no other way. It's pretty ugly in linux atm.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline sproingie

JGO Kernel


Medals: 202



« Reply #6 - Posted 2013-04-02 21:01:07 »

Too many environments fail to set up the associations for .jar, or change them capriciously (read: Windows) to rely on an executable .jar as your sole distribution mechanism.  At the very least, you need to ship a wrapper script, and if you want it to be polished, make it a genuine clickable installer.
Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2013-04-02 22:03:31 »

Yeah I can confirm that it doesn't work when double clicked. Apparently neither did my test jar. It only works from the command line. Either way, it's best not to distribute a JAR file and do like the others said Smiley

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 81
Projects: 15


★★★★★


« Reply #8 - Posted 2013-04-02 22:06:40 »

You could also use JarSplice, will wrap your jar and natives into a single shellscript (.sh) for linux, exe for windows and an .app for OS X.
Offline MatthewNicholls

Junior Devvie


Medals: 6
Exp: 6 years



« Reply #9 - Posted 2013-04-03 13:24:51 »

@matheus23 Thanks your suggestions. I can't do the first one as the options aren't there in linux mint. The second one is just what I need Cool. When I double click the script I get the options to 'Run in Terminal' 'Display' Cancel' or 'Run' which is actually better then just running the jar.
I hadn't considered that actually having the terminal would be a useful, now I can have some useful feed back at run time from the final program and not just in the IDE. Grin

my blog
"...Muahahhah.ahahah... pull the lever Egor!" ..."Yesh mashter"..click... click...click..buzzzzz".......Its Alive!"
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!