processing 2.2.1 -> How to compile a programme from the terminal

edited February 2015 in Using Processing

ACK, I've just seen this page :

https://github.com/processing/processing/wiki/Command-Line

I'm going to read through that now :oops:

I'm using Ubuntu 14.04

I can't find any concrete info on this so I'm wondering if anyone else does this? I'm currently using the Processing IDE but would like to use VIM. However I'm not sure how I would go about running things from the terminal.

I have seen that there's something called processing-java since version 2, and apparently Windows and Linux versions have this installed automatically. I don't get anything when I run processing-java help, and nothing comes up when I try a sudo apt-get install processing-java.

I'm just wondering what the best way to go about this is, at it would be ace if I could use VIM with it

Thanks :)

edit :

vco@geoHP:~/sketchbook/triangleTurn$ ./processing-java --sketch=/home/vco/sketchbook/triangleTurn --output=/home/vco/sketchbook --force --run
bash: ./processing-java: No such file or directory
vco@geoHP:~/sketchbook/triangleTurn$ 

Answers

  • Ok that didn't actually work, I'm not too sure what I did following that guide, I probably ended up installing processing twice or something....

    So - how to compile a Processing sketch from the terminal in Linux?

  • edited February 2015

    processing-java resides in the root directory of Processing once you installed it.
    Not sure why you expect it to be in your sketch folder...

  • ahh, duh... I thought it was automatically installed as a global command or something, whoops

    I'm not sure if this is the right command or not though?

    I just tried to run the following :

        /home/vco/processing-2.2.1/processing-java --sketch=/home/vco/sketchbook/triangleTurn --output=/home/vco/sketchbook --force --run
    

    and got these errors :

     sh: 0: getcwd() failed: No such file or directory
    Error occurred during initialization of VM
    java.lang.Error: Properties init: Could not determine current working directory.
        at java.lang.System.initProperties(Native Method)
        at java.lang.System.initializeSystemClass(Unknown Source)
    

    As I've given absolute paths the location that I run the command from shouldn't matter

    Ah no! Whatever I just did then just wiped out my sketch folder completely.

    :((

  • Note - I have a back up, just incase this seems more stupid / sympathy worthy than it is (certainly leans on the former....). Though it's 11 days old, damn... lesson learnt!

  • Yeah, I lost data with this --output parameter... :-(

    No idea about the getcwd error.

  • thought there might have been a more definite this is how one compiles processing from the command line in docs or somewhere tbh :(

    I'll probably start using intellij, or eclipse, dunno, any suggestions there? I prefer the look of intellij I think, and it's meant to be the default for Android which would be nice... I'm all ears though. cheers

  • edited February 2015

    Hi! I write all my Processing code in Vim and run everything through the command line on Linux.

    Firstly, you need to make sure that "processing-java" is in one of the bin directories on your computer - you should symlink it there, since it requires the directories around it, if that makes sense. After doing this, you should be able to run it from the command line like normal from any directory.

    Then I use the command:

    processing-java --run --force --output="./outputfolder" --sketch="../sketchfolder"

    from within the sketch folder, but you have to make sure that there is a .pde file with the same name as the folder name. And yeah, this will overwrite whatever you already have in your output folder, so be careful if it's something you want to save.

    Hope that helps!

  • hi @kimspindel! Only just go around to this. I'm going to have a go at it now.

    It worked :) That's great.

    So can I be lazy and ask if there's anything that you have in your .bashrc or .vimrc to help with these things?

    I'm thinking that there might be some handy aliases set up or such for working within processing. I've not used Vim extensively in terms of exiting, compiling and what not, so don't really have a workflow down (at all) on that front. I'm quite happy editing in it though.

    One thing is that there's no syntax highlighting in Vim when I open a pde at the moment, do write them in straight Java or...?

    thanks

  • Yay, glad to hear it worked!

    You should be able to get syntax highlighting for Processing by adding this script to Vim https://github.com/sophacles/vim-processing/tree/master/syntax It looks like that project has a lot more than just syntax highlighting, stuff for compiling etc. but I haven't looked into it yet (but it looks pretty good!)

    I wrote a small perl script http://pastebin.com/pdwK5E2h and put it into my /bin/ directory so that I only have to type "process" from the folder that I am working from. A disadvantage though is that it doesn't print to the console when I use this script.

    I usually switch between editing in Vim and compiling/running the sketch by pressing Ctrl-Z whilst in Vim - this puts Vim in the background and allows me to type in the console to do anything - and then write "fg" to resume the Vim session.

    There are also plenty of nice Vim plugins that you can install to ease switching between files etc.

    Maybe I should take a video of this or something :)

  • @kimspindel cheers I'll have a look at this later this eve :)

    re the video, I think that could be a good idea, I personally struggled to find anything concrete on this so it could be nice for others.

    If you decide to do it and want an insight into how little people might know feel free to ask ;)

Sign In or Register to comment.