Common issues with sketch names

edited November 2014 in Common Questions

Common issues with sketch names

You have to know how Processing works to better understand the issues.

When you hit Run on an unsaved sketch, Processing will save it in a temporary directory. Exact placement depends on your system – trick: use println(sketchPath("")); in a new, unsaved sketch to get an idea of where it goes.

Processing will process the code to make valid Java code. It will concatenate the content of all the .pde files, then will wrap it in a new Java class whose name is the name of your sketch. It will also add a main() method, and standard import statements, among other things. This Java code is then saved to a similar temporary directory and compiled to a .class file, still in temp. dir.

The consequence is that the sketch name must not use a Java class name (like ArrayList, if you use one in your sketch) or a class name you defined. Otherwise, in the first case, your class will hide the Java one, leading to strange results (eg. unknown constructor); and in the second case, you will get a message about a nested class hidden by an enclosing one).

Another restriction due to this generation mechanism: sometime you will get a cryptic message about too short prefix. That's Java complaining because Processing is using the name of your sketch to generate a random file, and this name is too short (eg. you named your sketch P5 or similar).

Tagged:
Sign In or Register to comment.