# Creating a new Tool - ArtStation

**URL:** <https://discourse.processing.org/t/creating-a-new-tool-artstation/8347>\
**Category:** Development\
**Created:** [February 13, 2019, 12:05pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347 "2019-02-13T12:05:33Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [February 13, 2019, 12:05pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/1 "2019-02-13T12:05:33Z")

</div>

Hello, I have created a tool I would like to share with the community, but I built it as a stand alone Java application. It functions in that respect, but I think that it would be most useful as a tool that you could access from the Processing IDE.

I have followed the steps for creating a tool in eclipse to the best of my abilities, and I was finally able to get it to build. But I am very unfamiliar with eclipse and now I just have this “HelloTool.java” file that doesn’t even run. When I try is just says the selection cannot be launched. Did I do something wrong in the set up?

Or if I have a working java application is there an easier way to turn it into a tool?

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [February 15, 2019, 8:11am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/2 "2019-02-15T08:11:00Z")

</div>

I believe you follow either of these instructions:

> [Tool Basics · processing/processing Wiki · GitHub](https://github.com/processing/processing/wiki/Tool-Basics)

> [GitHub - processing/processing-tool-template: Processing Tool Template for Eclipse](https://github.com/processing/processing-tool-template)

If the instructions did not work for you, then the docs needs to be updated. Do you have the code in github and publicly available?

Kf

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 11, 2019, 10:50am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/3 "2019-03-11T10:50:31Z")

</div>

Sorry for the delayed response. I was able to get the example project to work. The issue was on my end, not the instructions. I was using the incorrect sketchbook location, causing the tool to not show up in the tools menu.

Now I will attempt to get it to work with my actual tool instead of the default. Thank you for your response! If I face additional issues, should I add a response here to keep from cluttering the boards, or would a new post be better for visibility?

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 12, 2019, 12:04pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/4 "2019-03-12T12:04:27Z")

</div>

It did not take very long for me to face additional issues \>\_\<

So I am very new to Eclipse but I am struggling to understand the tool file structure. So say I have a separate package (the one that holds my application) that I want my tool to run. Where in the structure do I need to put my package so that I can access it from the tool? This is my current structure from following the instructions on tool template creation:

![structure](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f7174e35df0c040afc4ed4e0682308275ae21989.png)

Where do I put the code for my application?

Honestly this is the first time I have tried to increase the scope of my project from something personal that I have made to something that can be distributed to others, and I am really lost here.

This is the application that I am trying to incorporate into the tool:  
[https://github.com/jwilder4690/ArtStationApplication](https://github.com/jwilder4690/ArtStationApplication)

---

<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:** [March 12, 2019, 3:18pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/5 "2019-03-12T15:18:33Z")

</div>

Perhaps you should take a look on some other PDE tool source code, so you can have a better idea how to pull 1 out as well. 🧐

How about this 1: 😀

> **[OlivierVicario/Perceptual-ColorPicker](https://github.com/OlivierVicario/Perceptual-ColorPicker/tree/master/PerceptualColorPicker/src/template/tool)**
>
> Tool for Processing3. Choose from 3 to 7 colors from CIE Lab or Lch with different graphic tools - OlivierVicario/Perceptual-ColorPicker

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [March 14, 2019, 6:13am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/6 "2019-03-14T06:13:18Z")

</div>

I believe you need to change the folder name from _template_ to the name of your tool. Note that I am referring to your your Eclipse screenshot.

Then follow these instructions to add the library to your project: [http://www.oxfordmathcenter.com/drupal7/node/44](http://www.oxfordmathcenter.com/drupal7/node/44)

This is probably not a full solution as more tweaking might be needed it to get it to work.

Kf

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 14, 2019, 3:34pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/7 "2019-03-14T15:34:23Z")

</div>

Thank you both for your assistance getting me pointed in the right direction! With GoToLoop’s help I was able to get a dummy application to launch from the template tool.

Unfortunately there was a compatibility issue with my current application using lamba expressions and newer java version. The instructions state " Remember to compile the tool with compliance to java version 1.7 or 1.8 ( `javac -source 1.7 -target 1.7` ) or your Tool will not load properly."

Will using a .jar file allow me to wrap up my application and run on the newer compiler? Or am I going to have to go through my code and make it compatible with 1.8?

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [March 15, 2019, 7:01am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/8 "2019-03-15T07:01:53Z")

</div>

At the end [here](https://github.com/processing/processing/wiki/Supported-Platforms) you will find a discussion about Java versions.

I don’t think lambda expressions are supported atm as describe [here](https://github.com/processing/processing/issues/3054)

Kf

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 19, 2019, 11:09am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/9 "2019-03-19T11:09:02Z")

</div>

Hmmm, getting this to work is proving to be quite troublesome. After replacing all of my lambda expressions, I am able to get the tool to build. But when I run my tool from the processing window I get a very generic error message:

```auto
java.lang.NullPointerException
	at artstationapplication.GUI.initializeGUI(Unknown Source)
	at artstationapplication.ArtStationApplication.initSurface(Unknown Source)
	at processing.core.PApplet.runSketch(PApplet.java:10767)
	at template.tool.ArtStation$1.run(Unknown Source)

```

I don’t have any issues when running the my app independently, only when launched from within the tool, so I am at a loss as to how to debug this. I am also curious about the proper workflow for working on something like this. Currently I am forced to do the full build (30 seconds), boot up Processing (10 seconds) and then attempt to launch my tool. There has to be a better way to see if it will work without needing to do the full build.

---

<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:** [March 19, 2019, 5:29pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/10 "2019-03-19T17:29:18Z")

</div>

> [@justindwilder](#):
>
> Unfortunately there was a compatibility issue with my current application using lamba expressions and newer java version.

- Lambda is a Java 8 feature. Yet, the PDE can’t compile such code. 👎
- However, you can compile code w/ lambda outside the PDE. 😉
- You just need to make sure it’s `javac -source 1.8 -target 1.8`. 🧐
- The PDE can’t use code compiled w/ Java 9 and beyond yet. 💩

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 20, 2019, 11:12am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/11 "2019-03-20T11:12:51Z")

</div>

Thank you so much for the tips! 🤗

I did some practicing exporting and importing jars in eclipse, and I was able to get my application working when imported into a practice project by invoking the main method. Then I tried the same in my tool and it finally works!

Now I just need to do some ironing out the details, verifying that everything is working, and follow the rest of the tool instructions. Soon I should be able to share this with other Processing users! I am super grateful to both of you for helping me along 🥰

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 25, 2019, 11:00am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/12 "2019-03-25T11:00:53Z")

</div>

I am back with a new question. I am happily able to launch my application from my processing tool with something that looks like this:

```auto
  public void run() {

    System.out.println("Hello Tool. ##tool.name## ##tool.prettyVersion## by ##author##");
    System.out.println("Art Station may take a few moments to launch.");
    
    new Thread() {
        @Override
        public void run() {
        	String[] args = {""};
        	ArtStationApplication.main(args);
        }
    }.start();
  }
}

```

Using a separate thread for my application allowed me to continue interacting with Processing as normal when my tool was launched. However I get an error when I close my Application window and try to relaunch it from the tool menu. I get:

```auto
java.lang.IllegalStateException: Application launch must not be called more than once

```

Is this because my thread is still running, and therefore thinks that I cannot launch a new app? Is there a way to close my thread when my application closes? Or a better way to do this in general?

Here is my main method. I receive the same error if I duplicate the runSketch() line, so I know that calling the main again is the issue.

```auto
    public static void main(String[] args) {
            String[] processingArgs = {"Art Station"};
            ArtStationApplication app = new ArtStationApplication();
            PApplet.runSketch(processingArgs, app);
    }

```

I am looking for a better way of doing this that allows me to relaunch if the user happens to close my application, so that they don’t need to completely relaunch Processing each time.

---

<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:** [March 25, 2019, 12:07pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/13 "2019-03-25T12:07:50Z")

</div>

> [@justindwilder](#):
>
> Using a separate Thread for my application…

Both PApplet.**main()** & PApplet.**runSketch()** `static` methods “ignite” a PApplet as a Thread.

> [@justindwilder](#):
>
> However I get an error when I close my application window and try to relaunch it from the tool menu.

Thread::**start()** may `throw` an IllegalStateException:

1. [Thread (Java SE 11 & JDK 11 )](https://Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Thread.html#start())
2. [IllegalThreadStateException (Java SE 11 & JDK 11 )](https://Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalThreadStateException.html)

> It is never legal to start a thread more than once.

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [March 27, 2019, 10:03am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/14 "2019-03-27T10:03:10Z")

</div>

It doesn’t seems to be an issue with restarting the threads, as near as I can tell the JVM is only allowed to call Application.launch() once, and if you call it a second time you get the java.lang.IllegalStateException which I was receiving.

It wont even let me hide and show the application, because I received this error when trying to show it again from the tool run method:

```auto
java.lang.IllegalStateException: Not on FX application thread; currentThread = AWT-EventQueue-0

```

I think the best I can do is just minimize the window when the user closes. It is not my favorite solution, but I can’t think of any other way to make it work.

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [April 1, 2019, 10:42am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/15 "2019-04-01T10:42:12Z")

</div>

```auto
Process proc = Runtime.getRuntime().exec("java -jar .\\tool\\ArtStation\\tool\\ArtStationApplication.jar");

```

This only way I have found that will allow me to run my application more than once. Everything else that I have tried either gives me the previously mentioned errors or something similar. I have like four alternative ideas that I tried but nothing works. 😭

Is this method acceptable? It seems like it will be prone to errors because it is platform dependent and relies on getting the correct path to the jar file. But if I can go this route I will flesh it out and make sure it works.

EDIT:  
Nevermind, I got around the issue I had previously with the show call not being on the FX application thread! It looks to be working now!

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [April 8, 2019, 8:21pm UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/16 "2019-04-08T20:21:35Z")

</div>

I sent my links to Elie Zananiri per the instructions in the tool basics, but it also says to post on the forum to let them know about the existence of my tool.

My tool is available here:  
[https://jwilder4690.github.io/tools/ArtStation/index.html](https://jwilder4690.github.io/tools/ArtStation/index.html)

So I guess now I just wait to hear if everything is good to go.

---

<div class="post-metadata">

**Author:** ![justindwilder](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@justindwilder](https://discourse.processing.org/u/justindwilder)\
**Post date:** [May 22, 2019, 10:51am UTC](https://discourse.processing.org/t/creating-a-new-tool-artstation/8347/17 "2019-05-22T10:51:40Z")

</div>

After working with Elie I have repaired my tool’s project structure. I definitely created it incorrectly initially, which was causing some of my issues.

Now I am facing a new issue using third party libraries. Per the instructions, I need to add any external libraries to my libs folder, and also list them in the classpath in my build.properties file. I did so, but after I launch my tool from within Processing, I receive this error:

```auto
java.lang.RuntimeException: The processing.svg.PGraphicsSVG renderer is not in the class path.
at processing.core.PApplet.makeGraphics(PApplet.java:2280)
at processing.core.PApplet.createGraphics(PApplet.java:2188)
at artstationapplication.ArtStationApplication.exportSVGFile(Unknown Source)
(many more lines)...

```

Did I miss an instruction for using an external library?

My current project is here [https://github.com/jwilder4690/Art\_Station\_Tool](https://github.com/jwilder4690/Art_Station_Tool)
