Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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] Distributing runnable files  (Read 659 times)
0 Members and 1 Guest are viewing this topic.
Offline Graftwijgje

Senior Newbie


Medals: 1



« Posted 2013-11-04 15:50:42 »

Ello JGO,

I want to throw my code into a runnable file, I've tried Launch4j, which looks fine. But I don't understand half of what I should be filling in. And I figure it wouldn't be a bad thing to know how to make an executable file myself. Is there any place I can find a detailed description of why and what things are/do and where to find this info on my project?

Some specifics:
Project in eclipse.
Build path libs: JRE 7, lwjgl.jar, lwjgl_util.jar
My OS: windows 8 64bit

Excuses if this is a redundant post, just point out to me the search terms you used so I can wallow in self-shame and be better at searching next time. Because I haven't found anything that seems like what I'm looking for using the search.

[Edit:] Eclipse's export as executable jar & correcting directory hierarchy got the job done. The result for the curious: http://149.210.136.93/~ramus/shared/varelseExecJar.rar
Offline Seiya02

JGO Coder


Medals: 3
Projects: 4
Exp: 5 years


No Text Here :x


« Reply #1 - Posted 2013-11-04 16:39:19 »

Eclipse has the Function to make a runnable .jar file no? and for LWJGL you could just put the .dlls beside the .jar for beginning
Offline Graftwijgje

Senior Newbie


Medals: 1



« Reply #2 - Posted 2013-11-04 17:01:00 »

Hmm, yes, that seems to work. (Again I was overcomplicating things) Only now it can't find files (shaders, images) because they're not in the same directories anymore. Do you know an export-proof way of loading files?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #3 - Posted 2013-11-04 17:29:28 »

I want to throw my code into a runnable file, I've tried Launch4j, which looks fine. But I don't understand half of what I should be filling in.
Maybe give JarSplice a try, might be easier to use Smiley it also lets you handle natives by including them in the jar/executable.
Offline UprightPath
« Reply #4 - Posted 2013-11-04 17:58:49 »

Another option is to create a .bat file or something similar that they can use to run the game (So that if there's anything else you might need to do to set it up you can do so in the .bat). That's the route I turned to when there were issues with getting anything I ran to actually work.

Offline Graftwijgje

Senior Newbie


Medals: 1



« Reply #5 - Posted 2013-11-04 18:40:17 »

Ok, I got my proverbial "shit" straightened out.

I had no real concept of the term classpath and thus my directory structure in eclipse was like this;
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
-name of project-
--src
---package
----foo.java
----bar.java
--lib
--res
---images
----image.png
----pic.png
---shaders
----fragment.glsl
----vertex.glsl


using this line to load the resources when testing the code in eclipse.
1  
BufferedReader reader = new BufferedReader(new FileReader("res/shaders/fragment.glsl"));


When it should have been like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
-name of project-
--src
---package
----foo.java
----bar.java
---res.images
----image.png
----pic.png
---res.shaders
----vertex.glsl
----fragment.glsl
--lib


And use this to load the resources.
1  
2  
InputStream input = Renderer.class.getClass().getResourceAsStream("/res/shaders/fragment.glsl");
BufferedReader reader = new BufferedReader(new InputStreamReader(input));


As for distributing everything, this should fix my issues and un-complicate things for me. Thanks for the answers everyone! They should get me on my way just fine.
Offline Seiya02

JGO Coder


Medals: 3
Projects: 4
Exp: 5 years


No Text Here :x


« Reply #6 - Posted 2013-11-04 18:49:50 »

Okay, here's how I do it:
loading stuff with ("./texture/img1.png") as url for example i locate a folder called "texture" next to the jar and put the files inside it, works for me but they aren't in the jar anymore Smiley
Offline Graftwijgje

Senior Newbie


Medals: 1



« Reply #7 - Posted 2013-11-04 19:41:05 »

That's also an alternative Tongue
Offline ricardo

Senior Member


Medals: 2
Projects: 3



« Reply #8 - Posted 2013-11-04 21:41:03 »

Your file give me this error. I'm using Linux Xubuntu 12.04 (xfce 4.8 ).

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
ricardo@RicardoPc:~/Desktop/varelseExecJar$ java -jar /home/ricardo/Desktop/varelseExecJar/varelse.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1874)
   at java.lang.Runtime.loadLibrary0(Runtime.java:849)
   at java.lang.System.loadLibrary(System.java:1087)
   at org.lwjgl.Sys$1.run(Sys.java:73)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
   at org.lwjgl.Sys.loadLibrary(Sys.java:95)
   at org.lwjgl.Sys.<clinit>(Sys.java:112)
   at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
   at varelse.Renderer.setupOpenGL(Renderer.java:179)
   at varelse.Renderer.<init>(Renderer.java:65)
   at varelse.Main.<init>(Main.java:24)
   at varelse.Main.main(Main.java:19)
   ... 5 more



Also, you should always use your resources folder (anything external you will use) as source folder. With this enabled, eclipse can include all your stuff when compiling and create the right folders.
Right click on your folder >> build path >> Use as source folder.
Offline Graftwijgje

Senior Newbie


Medals: 1



« Reply #9 - Posted 2013-11-05 14:55:01 »

Sorry, I only put in the natives for windows. I tried it out on mac with mac natives but the error log wasn't very helpful (should read through it again, huge thing, hope to find a stacktrace). I don't have a linux machine to test on, and thus no linux version D:

Thanks for the eclipse tip! I'll try that too Wink
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #10 - Posted 2013-11-05 15:11:11 »

Go
File -> Export -> Runnable Jar File




Then Use JarSplice and add all the natives.

Offline ricardo

Senior Member


Medals: 2
Projects: 3



« Reply #11 - Posted 2013-11-05 17:12:35 »

Linux is free. You can install a small distro on a virtual machine or maybe boot with your pen.
Also, I forget to mention.
If you use your folder as recourse folder, you can access all your files just typing /foldername/your_file and you don't need to change all files path after compiling. Eclipse should create all correct folders and files.
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.

Pippogeek (40 views)
2014-09-24 16:13:29

Pippogeek (31 views)
2014-09-24 16:12:22

Pippogeek (21 views)
2014-09-24 16:12:06

Grunnt (47 views)
2014-09-23 14:38:19

radar3301 (29 views)
2014-09-21 23:33:17

BurntPizza (65 views)
2014-09-21 02:42:18

BurntPizza (37 views)
2014-09-21 01:30:30

moogie (44 views)
2014-09-21 00:26:15

UprightPath (53 views)
2014-09-20 20:14:06

BurntPizza (55 views)
2014-09-19 03:14:18
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!