How do you go from a Processing 2.2.1 applet in Eclipse to a Windows executable?

I have a rather large program that is becoming too difficult to manage in the Processing 2.2.1 IDE. I want to move it over to Eclipse, but I don't understand the mechanics of going from Eclipse to a windows executable file. This is example code .pde from Tablet4 library with the comments removed for space reasons.

import codeanticode.tablet.*;

Tablet tablet;

void setup() {
  size(640, 480);

  tablet = new Tablet(this); 

  background(0);
  stroke(255);  
}

void draw() {
  if (mousePressed) {
    strokeWeight(30 * tablet.getPressure());    
    line(pmouseX, pmouseY, mouseX, mouseY);    
  }

}

To go from Processing to a windows executable is pretty straight forward. You export the application and move the jpen-2-3-64.dll into the same folder as the generated executable and it works fine.

This is the Eclipse version:

import codeanticode.tablet.*;
import processing.core.*;

public class MainApp extends PApplet{
    Tablet tablet;

    public void setup() {
      size(640, 480);

      tablet = new Tablet(this); 

      background(0);
      stroke(255);  
    }

    public void draw() {
      if (mousePressed) {
        strokeWeight(30 * tablet.getPressure());
        line(pmouseX, pmouseY, mouseX, mouseY);    
      }   
    }   
}

With the external libraries added to the build path and the jpen-2-3-64.dll put in the project's library folder, it runs fine from Eclipse. But I cant figure out how to turn it into an executable as was done from the Processing IDE. I can't even get a runnable .jar The project is called BasicPen in Eclipse. In the right context menu I chose Export->Java->Runnable Jar file. In the launch configuration, there is only one choice "Papplet-BasicPen" I choose this and export it to a folder in the root directory. It finishes with warnings.

  Exported with compile warnings: BasicPen/src/MainApp.java
  duplicate entry: gluegen-rt.dll
  duplicate entry: gluegen-rt.dll
  duplicate entry: jogl_desktop.dll
  duplicate entry: jogl_desktop.dll
  duplicate entry: jogl_mobile.dll
  duplicate entry: jogl_mobile.dll
  duplicate entry: nativewindow_awt.dll
  duplicate entry: nativewindow_awt.dll
  duplicate entry: nativewindow_win32.dll
  duplicate entry: nativewindow_win32.dll
  duplicate entry: newt.dll
  duplicate entry: newt.dll
  Jar export finished with problems. See details for additional information.
    Could not find main method from given launch configuration.

I think that last line is the problem. When I try to run the jar, nothing happens and I'm pretty sure its because it can't find "main" What is the proper way to do this? I think if I can get to a runnable .jar I can find a wrapper program to turn that into a windows executable.

Tagged:

Answers

  • I get it now. An applet doesn't have a main so its impossible to make it an executable from Eclipse.

  • Answer ✓

    Do a quick sketch in processing ide, export it and look at the exported app for hints. See if it adds a main to the Java file, or adds something to a manifest file somewhere.

  • Yes, it has a main which the program I posted above is missing. I have to play with this more because I also need access to the Frame that's created.

    import processing.core.*; 
    import processing.data.*; 
    import processing.event.*; 
    import processing.opengl.*; 
    
    import codeanticode.tablet.*; 
    
    import java.util.HashMap; 
    import java.util.ArrayList; 
    import java.io.File; 
    import java.io.BufferedReader; 
    import java.io.PrintWriter; 
    import java.io.InputStream; 
    import java.io.OutputStream; 
    import java.io.IOException; 
    
    public class BasicDrawingExample extends PApplet {
    
    Tablet tablet;
    
    public void setup() {
      size(640, 480);
    
      tablet = new Tablet(this); 
    
      background(0);
      stroke(255);  
    }
    
    public void draw() {
    
      if (mousePressed) {
        strokeWeight(30 * tablet.getPressure());
    
        line(pmouseX, pmouseY, mouseX, mouseY);    
      }
    
         static public void main(String[] passedArgs) {
              String[] appletArgs = new String[] { "BasicDrawingExample" };
              if (passedArgs != null) {
                PApplet.main(concat(appletArgs, passedArgs));
              } else {
                PApplet.main(appletArgs);
              }
         }
    }
    
Sign In or Register to comment.