# Export Application Shows Blank Canvas

**URL:** <https://discourse.processing.org/t/export-application-shows-blank-canvas/44508>\
**Category:** Beginners\
**Created:** [May 29, 2024, 12:38pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508 "2024-05-29T12:38:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [May 29, 2024, 12:38pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/1 "2024-05-29T12:38:17Z")

</div>

Hi, I’ve got an app I’ve made over a few months that works fine when launched from Processing, but exporting to Apple Silicone app fails.

I’ve googled this a lot but nothing I’ve found has solved this.

Here’s what happens when I try to launch the exported app:

 ![Screenshot 2024-05-29 at 5.37.44 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/3/53e6be4573206ee4d2e3534e723b02c65269df5a.jpeg)

Here are my settings:

 ![Screenshot 2024-05-29 at 5.38.45 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/7/8749fd27a40f6b6c393e7d772795726ff96249e1.jpeg)

How can I get this working?

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [May 30, 2024, 12:40pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/2 "2024-05-30T12:40:49Z")

</div>

After more googling, I tried right-clicking the app icon and getting the contents. Then I navigated to the Java folder and double-clicked the terminal app icon.

It again launched to a gray screen. But then I looked at the terminal info, and it said it was generating a null-pointer error as it was not able to find a text file I was referencing. Which is odd, because I do not have that issue when using the app from Processing.

In any case, moving the text file to the data folder now allows it to launch correctly!

However, now in processing the original function that needed that text file isn’t working.

So, a victory for the original request, but a headache now to figure out the rest.

Thanks for reading, hope this helps someone.

Mike

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [May 31, 2024, 5:14pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/4 "2024-05-31T17:14:57Z")

</div>

Houston, we still have a problem. I thought I had figured this out, but I had not.

Here is a minimum example that does not work, using loadStrings.

Sketch code:

```auto
String[] optString = new String[10];
String strSampleText = "";

PFont f;

public void setup(){
 size(300, 300, JAVA2D);
 loadSavedPrefs();
 f = createFont("Arial",16,true); // Arial, 16 point, anti-aliasing on
 }
public void draw(){
background(255);
textFont(f,36);
fill(0);
noStroke();
text(strSampleText,110,150);
}

void loadSavedPrefs(){
 try{
   optString = loadStrings("options.txt");
 }
 catch(Exception e){
  e.printStackTrace();
  }
  strSampleText = optString[0];   
 }//end loadSavedPrefs()

```

Also, make a text file called “options.txt” and put it in to the sketch folder, [per instructions with loadStrings() reference](https://processing.org/reference/loadStrings_.html)

The options.txt file should simply have the word “Test” on one line, and nothing else in it.

If you run this sketch from processing, it works fine, loading “Test” to the canvas.

Now try exporting for Apple Silicone. If you double click the finished app, you get a blank screen!

If you right-click the app icon and choose Contents, then MacOS, then double click the command line version, it also runs with a blank screen, but you get the following message:

```auto
saveStringsTest.app/Contents/MacOS/saveStringsTest ; exit;
The file "options.txt" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
java.lang.NullPointerException: Cannot load from object array because "this.optString" is null
	at saveStringsTest.loadSavedPrefs(saveStringsTest.java:41)
	at saveStringsTest.setup(saveStringsTest.java:25)
	at processing.core.PApplet.handleDraw(PApplet.java:2051)
	at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1386)
	at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
2024-05-31 09:58:12.905 saveStringsTest[45953:1933493] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.

```

Can anyone try this? You can reproduce it in a second.

FURTHER MORE:

If you now make a “data” folder inside the sketch folder, and COPY the options.txt file there, and update the code thus:

```auto
optString = loadStrings("data/options.txt");

```

This ALSO works fine when running directly from processing, but ALSO FAILS when you export application, with same error.

FINALLY:

Take the previous code, with options copied into the data folder, and also copied into the sketch folder. Right-click the app icon, go to Contents, open Java folder, and paste ANOTHER copy of options.txt into it, you can launch the finished app and it works.

So it’s taking 3 copies of the options.txt file in 3 different folders to make this export correctly.

I thought I was losing my mind! Well, I am. But obvs we don’t want to have to do this silly goofy method!

Seems like a bug with the Processing Export function.

Does anyone have any idea how to get this fixed?

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [May 31, 2024, 5:42pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/5 "2024-05-31T17:42:29Z")

</div>

There is no bug in the Processing Export function, the issue is the directory path to your options file. It will be different for the sketch and exported application.

This should work in both the sketch (pre-export) and the exported app

```auto
optString = loadStrings(dataPath("") +"/options.txt");

```

`dataPath("")` returns the absolute path to the data folder.

All file resources e.g. text, graphics, sounds, fonts etc. that are required by the exported app should be placed in the `data` folder. I see you have discovered this for yourself. 😁

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [May 31, 2024, 5:58pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/6 "2024-05-31T17:58:37Z")

</div>

Are you rescuing me even if it’s not your lib?

Thank you so much - I’ve spent a couple frustrating hours on this.

Your solution works perfectly. Shocker 🙂

I’m not clear on why simply referencing “data/options.txt” doesn’t work? I don’t have to use the special absolute path reference you shared with any of the other resources I’ve got, for tons of images for example…

In any case, this is absolutely wonderful. Thank you kind sir 🥰

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [May 31, 2024, 7:51pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/7 "2024-05-31T19:51:06Z")

</div>

> [@Thundercat](#):
>
> I’m not clear on why simply referencing “data/options.txt” doesn’t work?

It doesn’t work because it is the path relative to the sketch folder. Once the sketch is exported the relative path would have to be from the executable file but that is not the same. The `dataPath("")` method returns the absolute path to the `data` folder irrespective of sketch or executable whichever is being used.

So in a Processing sketch the lines

`optString = loadStrings(dataPath("") +"/options.txt");`  
and  
`optString = loadStrings("data/options.txt");`

are synonymous but not for the exported app.

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [May 31, 2024, 8:06pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/8 "2024-05-31T20:06:57Z")

</div>

Thank you so much Peter. As per usual!!

Also, it’s interesting that we don’t have to do this for images. I just plop them in the data folder and refer to them and they export into a compiled app without complaint.

But you got it working for me! So thanks again!!

Mike

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 31, 2024, 9:12pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/9 "2024-05-31T21:12:11Z")

</div>

> [@quark](#):
>
> `optString = loadStrings(dataPath("") + "/options.txt");`

We can also pass the string as an argument for function [**dataPath()**](https://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#dataPath-java.lang.String-) w/o the slash `/`:  
`optString = loadStrings(dataPath("options.txt"));`

When running from the PDE (Processing’s IDE), by default, all loading functions check both the sketch’s root folder and then its subfolder “data/” for the file.

Therefore, we don’t need to use **dataPath()** for loading operations.

However, all saving functions save the file to the sketch’s root folder.

If we wish to force it into subfolder “data/”, we need to use **dataPath()** to create the path string:  
`saveStrings(dataPath("options.txt"), optString);`

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [May 31, 2024, 9:36pm UTC](https://discourse.processing.org/t/export-application-shows-blank-canvas/44508/10 "2024-05-31T21:36:42Z")

</div>

@GoToLoop that’s wonderful sharing! Thank you!!

Mike
