Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Need halp (help) testing native binaries on Mac and Linux  (Read 15534 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd
« Posted 2015-04-21 01:11:49 »

Hello. I am looking for people who happen to have a Mac and/or a Linux computer to test some simple native binaries. I am working on some deployment related stuff like embedding a JRE so people don't need Java and making our game look more professional with native binaries. This requires some testing, and I'm all out of Linux and Mac computers. If someone could lend me an hour of their times, I could probably figure this out relatively quickly. I'd prefer to work over Skype, but JGO PMs would work too. Please post in this thread if you are interested in helping out and I will PM you my Skype name. All findings will eventually be posted to this forum within a few a days of course.

Thank you for your time.

PS: Apparently "Need help testing native binaries on Mac and Linux" is not an informative subject of a thread. >___>

Myomyomyo.
Offline teletubo
Global Moderator

JGO Wizard


Medals: 76
Projects: 4
Exp: 8 years



« Reply #1 - Posted 2015-04-21 03:26:34 »

I have a mac book pro.
my skype name is
String skypeName = "demian."+ myForumName;

Offline rwatson462
« Reply #2 - Posted 2015-04-21 08:15:49 »

Hi,

I have a late 2012 mac book pro and I'm free all day on Saturday if that's any good for you.

If you would like me to help then I'll get a Skype username organised Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jesse

JGO Coder


Medals: 23



« Reply #3 - Posted 2015-04-21 10:46:55 »

If PM is acceptable, I could help out that way (I have a Mac and a Linux machine available).
Offline nsigma
« Reply #4 - Posted 2015-04-21 12:37:50 »

Hello. I am looking for people who happen to have a Mac and/or a Linux computer to test some simple native binaries.

Out of interest, how are you making them?

.. making our game look more professional with native binaries.

Have you looked at binary packaging (mainly .deb) on Linux too?  It's easy enough, and tends to give better OS integration.

I've got a range of machines, all currently running Ubuntu.  No Skype though!  PM me if you need to.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline Opiop
« Reply #5 - Posted 2015-04-21 19:35:02 »

I have a 2010 Mac, but no Skype. If you need any testing feel free to PM me!
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #6 - Posted 2015-04-22 00:03:57 »

I've got a Windows 8.1 Machine (Surface Pro 3), a low-range Linux machine (ubuntu), a high-range Linux Machine (ubuntu + i3wm) and possibly a vista machine.
PM me if you're interested.

Offline theagentd
« Reply #7 - Posted 2015-04-22 15:12:18 »

Hello, everyone. Sorry for the late reply.

I've started an article here for making native binaries for Windows. The next step is OSX and Linux. So far, I am unsure what the best course of action is, as I have very little personal experience with these two operating systems, so before I can get started with testing I need to figure those points out first.

What kind of executables are Linux users used to? Simply making a shell script and not giving it an extension at all and somehow marking it executable (?) seems to be the way to go here. Is it possible to give such a file a custom icon? Is a desktop entry (.desktop) the way to go to get a custom icon?

For Mac I'm even more confused. It seems like the most recommended way of doing this is to create a .app folder which has a specific structure and some configuration files, but in theory shouldn't the same files as on Linux work?

Myomyomyo.
Offline rwatson462
« Reply #8 - Posted 2015-04-22 15:31:24 »

The preferred method of installation and usage on OSX is to package the whole app as a .app folder and enclose it in a DMG disk image that the user just drags across to their applications folder.

How exactly we go about making an executable is not something I've ever done before but it can't be that hard, surely Wink.   I imagine it'll end up similar to Linux version - execute a script that then runs the Jar?

I'm sure your googly skills are far better than mine, but I found a page with info about how the .app folder works and it's basic structure:
https://mathiasbynens.be/notes/shell-script-mac-apps
Offline theagentd
« Reply #9 - Posted 2015-04-22 15:41:40 »

Yes, I found the Appify program as well, but since I don't have a Mac it's fairly useless for me. >___> Manually composing up a .app folder and packing it to a DMG file seems like the only solution.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 486
Exp: 7 years



« Reply #10 - Posted 2015-04-22 16:08:44 »

I haven't tried it (I also don't have a Mac) but packr says it supports .apps.
Offline theagentd
« Reply #11 - Posted 2015-04-22 16:30:49 »

INTRODUCING JAPPIFY

The brand new solution to all the world's problems! Just kidding, it's just a hacked together port of the Appify script.

Jappify source code
Executable jar file (uses command line arguments, see source code)
Test .app generated (JOptionPane hello world, ~40MB due to JRE)

The jar takes in 4 arguments:

 - gamePath: Path to the game's folder which includes the jar and all resource files.
 - relativeJarPath: Path to the jar relative to the base game folder. If your jar is in a folder called "jar" in your game folder, then specify "jar/<jar name>.jar".
 - jrePath: Path to an extracted JRE. It expects the JRE to have the bin/, lib/ and man/ folders along with several files right inside the JRE folder, so you'll need to do some manual unpacking from the .tar.gz JRE file.
 - appName: Name of the generated app.

If anyone could test the .app I created on OSX and/or possibly check and fix the source code if there's any problem somewhere I'd really appreciate it. Debugging stuff on the internet is just too time-consuming... x___x


EDIT: May want to change the classpath of the game it runs to the game folder in the shell script it generates...


I haven't tried it (I also don't have a Mac) but packr says it supports .apps.
Sadly it doesn't handle Oracle JDKs and icons. Good find, though.

Myomyomyo.
Offline nsigma
« Reply #12 - Posted 2015-04-22 19:56:10 »

What kind of executables are Linux users used to? Simply making a shell script and not giving it an extension at all and somehow marking it executable (?) seems to be the way to go here. Is it possible to give such a file a custom icon? Is a desktop entry (.desktop) the way to go to get a custom icon?

Bear something in mind - Linux isn't an OS - Ubuntu (for example) is an OS.  If you want something that's going to properly integrate with icons, etc. you're likely going to have to make a package suitable for the OS.  I've seen a pure-Java RPM builder before, but not sure if there's a .deb builder.  You should be able to make packages very easily in a Linux VM though.

Not sure if you looked at the somewhat hidden link in my reply above - it's a blog post I wrote on how the Praxis LIVE package is built - Packaging as a .deb

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline teletubo
Global Moderator

JGO Wizard


Medals: 76
Projects: 4
Exp: 8 years



« Reply #13 - Posted 2015-04-22 20:52:06 »

when I first tried to run on my Mac Book Pro I had an error:

./HelloWorld: line 2: jre/bin/javaw: No such file or directory

I modified the HelloWorld to point to jre/bin/java and it gave a beautiful dialog saying HellWorld.

Offline theagentd
« Reply #14 - Posted 2015-04-22 21:01:27 »

What kind of executables are Linux users used to? Simply making a shell script and not giving it an extension at all and somehow marking it executable (?) seems to be the way to go here. Is it possible to give such a file a custom icon? Is a desktop entry (.desktop) the way to go to get a custom icon?

Bear something in mind - Linux isn't an OS - Ubuntu (for example) is an OS.  If you want something that's going to properly integrate with icons, etc. you're likely going to have to make a package suitable for the OS.  I've seen a pure-Java RPM builder before, but not sure if there's a .deb builder.  You should be able to make packages very easily in a Linux VM though.

Not sure if you looked at the somewhat hidden link in my reply above - it's a blog post I wrote on how the Praxis LIVE package is built - Packaging as a .deb
Hmm. Is it reasonable to expect Linux users to be less sensitive to stuff like icons? Do you think the average user would be okay with just a generic no-extension executable file?

when I first tried to run on my Mac Book Pro I had an error:

./HelloWorld: line 2: jre/bin/javaw: No such file or directory

I modified the HelloWorld to point to jre/bin/java and it gave a beautiful dialog saying HellWorld.
Thanks a lot for testing!!! That's really weird though. Oh, the bin/ folder doesn't have javaw. -_____- I wonder why that is... Anyway, I've fixed that problem.

One more question: Did it pop up a terminal window or did it start silently?

EDIT: Medal for "HellWorld".
EDIT2: And for helping of course. ^_^

Myomyomyo.
Offline teletubo
Global Moderator

JGO Wizard


Medals: 76
Projects: 4
Exp: 8 years



« Reply #15 - Posted 2015-04-22 21:50:18 »

Ok, Actually I first tried clicking the .app and nothing happened.
Then as I told before I went to my terminal and checked the script, fixed it and ran  ./HelloWorld from the terminal.

Now I tried again clicking the app (having the script fixed) and still nothing happened :/

Offline theagentd
« Reply #16 - Posted 2015-04-22 22:24:56 »

So clicking it isn't working? Damn it.

Myomyomyo.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #17 - Posted 2015-04-22 22:30:43 »

IIRC the working-directory on Mac OS X is the user-dir, not the directory of the double-clicked file / app.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline nsigma
« Reply #18 - Posted 2015-04-22 22:31:00 »

Is it reasonable to expect Linux users to be less sensitive to stuff like icons?

Probably not, but it's reasonable to expect there'd be less of them!  Wink  Know your audience - go with the easiest approach until you know putting extra time in is worth the effort.

Do you think the average user would be okay with just a generic no-extension executable file?

Getting it all in a single executable is probably more work than creating the package file.  Just stick a folder with a shell launcher in an archive.  If you're clever about it you should be able to use the same launcher and structure for OSX and Linux.

Oh, the bin/ folder doesn't have javaw. -_____- I wonder why that is...

AFAIK javaw is a Windows-only concept.  I don't have OSX to test, but I noticed your app bundle has a somewhat different structure to mine, and I know mine works!  Wink  As Praxis LIVE is a NetBeans RCP application, it uses the build process from that, which seems to handle this well.  It might be worth having a look at the Praxis LIVE app bundle - IIRC the Contents/MacOS folder just contains a symlink to a folder in Contents/Resources, which has the same structure as the application folder in the zip bundle and .deb package.  All use the same shell launch script, which is part of the NetBeans RCP build, and is used for both OSX and Linux.

Also, I wonder if you're being bitten by issues with working directory, which behaves differently on Windows?  That shell launcher script also has logic in it to find absolute paths to resources based on its own location.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline theagentd
« Reply #19 - Posted 2015-04-23 13:03:18 »

IIRC the working-directory on Mac OS X is the user-dir, not the directory of the double-clicked file / app.
Hmm. Any way of overriding that or getting the path of the double-clicked file? Sounds rather useless otherwise.

Do you think the average user would be okay with just a generic no-extension executable file?

Getting it all in a single executable is probably more work than creating the package file.  Just stick a folder with a shell launcher in an archive.  If you're clever about it you should be able to use the same launcher and structure for OSX and Linux.
Ah, yeah, that's what I meant. Not packing it all up into a single executable, but creating a shell script which boots it all up with the right VM and all.

Oh, the bin/ folder doesn't have javaw. -_____- I wonder why that is...

AFAIK javaw is a Windows-only concept.  I don't have OSX to test, but I noticed your app bundle has a somewhat different structure to mine, and I know mine works!  Wink  As Praxis LIVE is a NetBeans RCP application, it uses the build process from that, which seems to handle this well.  It might be worth having a look at the Praxis LIVE app bundle - IIRC the Contents/MacOS folder just contains a symlink to a folder in Contents/Resources, which has the same structure as the application folder in the zip bundle and .deb package.  All use the same shell launch script, which is part of the NetBeans RCP build, and is used for both OSX and Linux.

Also, I wonder if you're being bitten by issues with working directory, which behaves differently on Windows?  That shell launcher script also has logic in it to find absolute paths to resources based on its own location.
Sigh. This would be so much easier to figure out if I actually had a Mac... Is there any significant difference between how shell scripts behave on Linux and Mac?

Myomyomyo.
Offline nsigma
« Reply #20 - Posted 2015-04-23 14:38:11 »

IIRC the working-directory on Mac OS X is the user-dir, not the directory of the double-clicked file / app.
Hmm. Any way of overriding that or getting the path of the double-clicked file? Sounds rather useless otherwise.

It's the same on Linux - it's Windows that behaves oddly!  Wink

You have potentially two things to deal with - finding the directory of your launcher and traversing symlinks to the actual executable script.

Sigh. This would be so much easier to figure out if I actually had a Mac... Is there any significant difference between how shell scripts behave on Linux and Mac?

Like I said, the NetBeans launcher script works on both.  I just looked for an old shell script launcher I had to handle this and it has an identical start to the NetBeans launcher script (pretty sure I got it from a website somewhere), but anyway ...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
#!/bin/bash
PRG=$0

while [ -h "$PRG" ]; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
    if expr "$link" : '^/' 2> /dev/null >/dev/null; then
   PRG="$link"
    else
   PRG="`dirname "$PRG"`/$link"
    fi
done

progdir=`dirname "$PRG"`


At the end of that, progdir contains the directory holding your actual launcher script.  My old script called cd "$progdir", but you would probably be better working with absolute paths from then.

eg. something like IIRC

1  
"${progdir}/jre/bin/java" ARGS




Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline theagentd
« Reply #21 - Posted 2015-04-23 22:57:33 »

I... have no idea what that script is supposed to do... or how it does it...

Myomyomyo.
Offline Cero
« Reply #22 - Posted 2015-04-24 03:17:10 »

Sigh. This would be so much easier to figure out if I actually had a Mac... Is there any significant difference between how shell scripts behave on Linux and Mac?
Not really as far as I could tell. I'm sure if you are hardcore at shell scripting some differences do appear, but aside from some commands/tools not being available on one system versus the other for more or less obvious reason, didn't seem much different.

IIRC the working-directory on Mac OS X is the user-dir, not the directory of the double-clicked file / app.
I do recall this. The devil can in those details...

Offline rwatson462
« Reply #23 - Posted 2015-04-24 07:13:02 »

Quote from: Riven
IIRC the working-directory on Mac OS X is the user-dir, not the directory of the double-clicked file / app.

I just spent some time looking into these scripts and by changing the HelloWorld script to run "pwd" and output it to a text file I found out the following:

Line 1 is me double-clicking the .app package from my /Applications folder
Line 2 is me double-clicking the .app package from my ~/Desktop folder
Line 3 is me running ./HelloWorld from a Terminal window after CD'ing into the Contents/MacOS folder (when it was on my Desktop still)
Line 4 is a bit strange as it hasn't got the capital S on the end of MacOS like the previous line. This was done after moving the .app package back into my /Applications folder
Line 5 was obtained my CD'ing into the /Applications/helloworld.app folder from the Terminal and running ./Contents/MacOS/HelloWorld

1  
2  
3  
4  
5  
/
/
/Users/robwatson/Desktop/HelloWorld.app/Contents/MacOS
/Applications/HelloWorld.app/Contents/MacOs
/Applications/helloworld.app


So all the operations from the Terminal worked pretty much as expected but by double-clicking it we are totally lost as to where the app is running from :/
Offline nsigma
« Reply #24 - Posted 2015-04-24 07:29:38 »

I... have no idea what that script is supposed to do... or how it does it...

Can't remember much of the how ... did work it out when I first saw it.  Wink

Obviously didn't explain the "what" very well, though  Emo

This isn't a whole script, it's a fragment that goes at the top of your launcher script so that it can find out where it is.  Your problem on OSX and Linux is that the working directory is not set to the location of the launcher you click.  Once this fragment has run, the progdir variable will contain what you want to be the working directory.

So, if after the fragment you call
cd "$progdir"
, your working directory would then be like Windows - the location of the script.  However, it is better (more robust) to call things with absolute locations as the example at the end of my previous post.

The loose how - $0 contains the full path called (eg. your launcher).  The naive approach would just use dirname on this to get the directory.  The while loop handles the fact that if you or your user has created a link to the launcher script, $0 will be the location of the link instead - the while loop handles dereferencing through links to find the actual launcher location.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline rwatson462
« Reply #25 - Posted 2015-04-24 07:41:28 »

Further investigation found me this snippet:

1  
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )


Not sure exactly how it works but the outcome seems to be is sets a variable (DIR) to the current directory of the script that is being run.

I changed the HelloWorld script to this:

1  
2  
3  
4  
5  
#!/bin/sh

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd $DIR
./jre/bin/java -jar game/helloworld.jar


And it works just fine when double-clicking the .app package in my /Applications folder.  Also moved it around a bit and had it in ~/Desktop and ~/Applications and it worked fine in both of those.








Oh, I see someone more knowledgable than me (nsigma) also posted more info on the expanded version of the script.  I reckon you need to just put that bit of code in the top of your script and go from there Smiley
Offline gouessej
« Reply #26 - Posted 2015-04-24 13:29:20 »

theagentd, why don't you look at my stuff? I use some Java code to convert images into ico format and it's under a permissive license in the project Apache Commons Imaging:
https://github.com/gouessej/commons-imaging/commits/trunk
I use Ant to call my code. Don't reinvent the wheel, you're gonna solve once again the same problems than some developers including me had in the past, i.e with BASH_SOURCE:
http://stackoverflow.com/a/246128

I haven't tried it (I also don't have a Mac) but packr says it supports .apps.
I used PackR before writing my own tool (JNDT). I confirm that it works very well with Mac OS X >= 10.8. Our tools work very well under GNU Linux, Mac and Windows. Mine is a bit less documented. You can use Wix toolset to create a MSI file, feel free to use my template (work in progress):
http://stackoverflow.com/questions/29748422/how-to-create-a-msi-windows-installer-for-a-java-program

Note that PackR is able to minimize the JRE, you can still do it by yourself. Using Oracle Java instead of OpenJDK is less permissive, look at the Oracle Binary Code License Agreement.

Have you ever used javapackager?

Good luck.

Edit.: Some working native self contained application bundles I made.

Julien Gouesse | Personal blog | Website | Jogamp
Offline theagentd
« Reply #27 - Posted 2015-04-25 01:57:38 »

Thanks, everyone! I'll see if I can do some more testing tomorrow!

Myomyomyo.
Offline nsigma
« Reply #28 - Posted 2015-04-25 11:30:10 »

I use some Java code to convert images into ico format

Interesting.  May have to look at that.

I'm using libicns.  Judging from that page, this is in use on iConvert Icons - which seems to include a free online converter.

Don't reinvent the wheel, you're gonna solve once again the same problems than some developers including me had in the past, i.e with BASH_SOURCE:
http://stackoverflow.com/a/246128

Agree with the sentiment, obviously, but you may want to check the comments below it - a) caveats on cd usage, and b) some bits don't work on OSXWink

Bear in mind the script code I posted above is called every single time someone launches NetBeans on Linux or OSX.  Which reminds me, it has a GPL w/CPE or CDDL header in NetBeans, though nothing in the platform build harness - either way it should be fine to use, just you might want to credit it!  persecutioncomplex

@rwatson462 - does swapping out the HelloWorld script for this also work?   Nothing like coding blind, but I think this should achieve the same with symlink resolution and not using cd.  Undecided

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
#!/bin/sh
PRG=$0

while [ -h "$PRG" ]; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
    if expr "$link" : '^/' 2> /dev/null >/dev/null; then
   PRG="$link"
    else
   PRG="`dirname "$PRG"`/$link"
    fi
done

progdir=`dirname "$PRG"`

"${progdir}/jre/bin/java" -jar "${progdir}/game/helloworld.jar"

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline rwatson462
« Reply #29 - Posted 2015-04-25 20:19:29 »

@nsigma... Yep, that worked fine from multiple directories and also launched from a symlink on the desktop Smiley
Pages: [1] 2
  ignore  |  Print  
 
 

 
Riven (579 views)
2019-09-04 15:33:17

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

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

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

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

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

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

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

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

nelsongames (5114 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

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
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!