New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sketchPath() returns user.home in exported apps on OSX #2181

Closed
ElectricJack opened this Issue Oct 29, 2013 · 7 comments

Comments

Projects
None yet
4 participants
@ElectricJack

ElectricJack commented Oct 29, 2013

Running the following:

println( "javaVersionName: "+ javaVersionName );
println( "java.home:       "+ System.getProperty("java.home") + "\n");
println( "os.arch:         "+ System.getProperty("os.arch") );
println( "os.name:         "+ System.getProperty("os.name") );
println( "os.version:      "+ System.getProperty("os.version") + "\n");
println( "user.home:        "+ System.getProperty("user.home") );
println( "user.dir:        "+ System.getProperty("user.dir") );
println( "dataPath():      "+ dataPath("") );
println( "sketchPath():    "+ sketchPath("") );

exit();

Returns expected results when run from the processing editor:
screenshot 2013-10-28 17 11 55

However when running the exported app it returns invalid results for sketchPath():

JKERNOAKOSX2:sketchPathDiag jack.kern$ ./run.sh
javaVersionName: 1.7.0_45
java.home:       /Users/jack.kern/Desktop/sketchPathDiag/sketchPathDiag.app/Contents/PlugIns/jdk1.7.0_45.jdk/Contents/Home/jre

os.arch:         x86_64
os.name:         Mac OS X
os.version:      10.8.5

user.home:        /Users/jack.kern
user.dir:        /Users/jack.kern
/Users/jack.kern/Desktop/sketchPathDiag/sketchPathDiag.app/Contents/Java/data
dataPath():      /Users/jack.kern/Desktop/sketchPathDiag/sketchPathDiag.app/Contents/Java/data
sketchPath():    /Users/jack.kern/
@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Oct 29, 2013

Member

Yeah, it's a problem with Oracle Java (which behaves that way partly due to Apple's sandboxing rules). I'll have to add a workaround.

Member

benfry commented Oct 29, 2013

Yeah, it's a problem with Oracle Java (which behaves that way partly due to Apple's sandboxing rules). I'll have to add a workaround.

@ElectricJack

This comment has been minimized.

Show comment
Hide comment
@ElectricJack

ElectricJack Oct 29, 2013

Cool.. I'll probably implement my own off dataPath() for the time being as well. Thanks for the quick response!

Jack

ElectricJack commented Oct 29, 2013

Cool.. I'll probably implement my own off dataPath() for the time being as well. Thanks for the quick response!

Jack

@01010101

This comment has been minimized.

Show comment
Hide comment
@01010101

01010101 Nov 26, 2013

This should work as a workaround

String myAppName = "sketchPathDiag.app";
// Your exported sketch name with the .app extention

String pathToData = dataPath("");
/*
Returns an absolute path like this
/Users/jack.kern/Desktop/sketchPathDiag/sketchPathDiag.app/Contents/Java/data
*/

// Clean it
pathToData = pathToData.replaceAll(myAppName+"/Contents/Java","");
/*
You'll get what you need and can read/write files from it
/Users/jack.kern/Desktop/sketchPathDiag/data
*/

01010101 commented Nov 26, 2013

This should work as a workaround

String myAppName = "sketchPathDiag.app";
// Your exported sketch name with the .app extention

String pathToData = dataPath("");
/*
Returns an absolute path like this
/Users/jack.kern/Desktop/sketchPathDiag/sketchPathDiag.app/Contents/Java/data
*/

// Clean it
pathToData = pathToData.replaceAll(myAppName+"/Contents/Java","");
/*
You'll get what you need and can read/write files from it
/Users/jack.kern/Desktop/sketchPathDiag/data
*/

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Apr 15, 2014

Member

Fixed for 2.1.2.

Member

benfry commented Apr 15, 2014

Fixed for 2.1.2.

@benfry benfry closed this Apr 15, 2014

@maudiruiz

This comment has been minimized.

Show comment
Hide comment
@maudiruiz

maudiruiz Feb 11, 2015

This is not repaired for Processing 2.2.1 running the command and just getting "/Users/myUser"
I can hardcode the path but it does not work when exporting to a .app
Any ideas on how to make a local patch to solve it @benfry @01010101 ?

Thanks!

maudiruiz commented Feb 11, 2015

This is not repaired for Processing 2.2.1 running the command and just getting "/Users/myUser"
I can hardcode the path but it does not work when exporting to a .app
Any ideas on how to make a local patch to solve it @benfry @01010101 ?

Thanks!

@01010101

This comment has been minimized.

Show comment
Hide comment
@01010101

01010101 Feb 11, 2015

I used this workaround :

Say you want to use a file name yourfilename.ext in the data folder located at the root of your exported app :

String fullpath = dataPath("").replaceAll("NameOfYourSketch.app/Contents/Java/", "")+"/yourfilename.ext"

PS : take a look at my previous post, which explains it in details.

01010101 commented Feb 11, 2015

I used this workaround :

Say you want to use a file name yourfilename.ext in the data folder located at the root of your exported app :

String fullpath = dataPath("").replaceAll("NameOfYourSketch.app/Contents/Java/", "")+"/yourfilename.ext"

PS : take a look at my previous post, which explains it in details.

@benfry benfry reopened this Feb 12, 2015

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Aug 12, 2015

Member

Just confirmed to be working in 3.0 beta 3.

Member

benfry commented Aug 12, 2015

Just confirmed to be working in 3.0 beta 3.

@benfry benfry closed this Aug 12, 2015

@onar3d onar3d referenced this issue Jul 26, 2016

Open

wondering.. #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment