0

Basically, the question is how to use ProcessinJS compiler to use it in the same way that CoffeeScript allows writing client side code, except that it would be in Java language. I'm thinking of live coding in Java in the browser similar to the "Try CoffeeScript" option in the CoffeeScript website.

1
  • I'm confused... what do you think the relationship between ProcessingJS and Java is? Commented Jul 21, 2011 at 3:26

1 Answer 1

2

This is a very confusing question. Let's go through this step by step:

  • The Processing language is designed to be syntactically similar to Java, and it is normally compiled to Java (quoth the Wikipedia article on Processing: "the code is translated into pure Java before compiling").
  • ProcessingJS is a project with two parts: 1) a JS library for using Canvas, and 2) a compiler (written in JS) that compiles Processing code to JS code that uses the aforementioned library.
  • It would certainly be possible to use ProcessingJS to compile Processing code to JS code that runs in real-time directly in the browser. Indeed, this has already been done. (Update: The interactive ProcessingJS editor that link used to go to has been replaced by http://sketchpad.cc/.)

But, when you talk about using ProcessingJS to do "live coding in Java in the browser"... well, ProcessingJS doesn't generate Java. Only the Processing compiler written in Java generates Java. If you want to work with Processing code in the browser and get Java output, you should either:

  1. Sidestep ProcessingJS altogether and use a Java applet, or
  2. Use ProcessingJS to compile and run your Processing code in real time, and use Ajax to send the Processing code to the server for compilation to Java.
Sign up to request clarification or add additional context in comments.

2 Comments

Sorry if the question was confusing. I specifically meant using the ProcessingJS compiler to code against the HTML DOM or any other JavaScript library other than ProcessingJS itself. For example I don't want use the tricky javascript OO for creating classes, and instead use Java language to generate JS. I want it all happen in the browser without Java applets or other plug-ins.
OK, I see what you're saying now. The short answer is no, ProcessingJS only converts Processing code to JS that targets the canvas; it can't be used as a more general Java-to-JS converter. The only project I know of that converts Java to JS is GWT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.