Processing not exported a useable .exe file in Win 10 64 bit.

When I export my processing sketch, the following java source code is produced -

import processing.core.*; 
import processing.data.*; 
import processing.event.*; 
import processing.opengl.*; 

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 generatorv2 extends PApplet {

HScrollbar hs1;
float counter;
//float count;
PImage img;
PImage img2;
PImage img3;
int widthx=10;
int fillx=0xff57DDE8;
int rotate;
float i=360;
float x, y;
float d;

float prevX=0.0f, prevY=0.0f;
float numOfWaves=8;
float angle=0;
boolean isLoaded=false;
float xpos, ypos;//x and y position of bar

float cbrt;
public void setup()
{
  coilx = 450.0f;
  coily = 245;
  background(0);
  noStroke();
  hs1 = new HScrollbar(100, 500, 200, 30, 1);
  counter=i;

  img=loadImage("paddlewheel2.png");
  img.resize(img.width/2, img.height/2);
  img2=loadImage("tap.png");
  img3=loadImage("cro.png");
  //dcbrt=1;
  coil=loadImage("threecoil.png");
  coil.resize(coil.width/2, coil.height);
}

public void draw()
{
  background(0);
  hs1.update();
  hs1.display();
  Graph();

  image(img2, 148, 19);
  if (isLoaded)image(img3, 350, 0);
  fill(fillx, 75);
  noStroke();
  rect(230, 105, widthx, 200);
  counter+=i;
  // Test if the cursor is over the box 
  if (mouseX > coilx-boxSize && mouseX < coilx+boxSize) 
    //mouseY > by-boxSize && mouseY < by+boxSize) 
  {
    overBox = true;  
    if (!locked) {
    }
  } else {

    overBox = false;
  }

  image(coil, coilx, coily);


  translate(width/2, height/2);
  rotate(counter/360);
  translate(-img.width/2, -img.height/2);
  image(img, 0, 0);

  //println(coilx);
  //println(d);
  //println(numOfWaves);
  //println(y);
  //println(mouseX);
}

public void Graph() {
  smooth();
  stroke(0xffFC0D31);
  strokeWeight(1);
  image(img3, 350, 0);
  d=.198f*(coilx-320);
  cbrt=d*d*d;
  for (int count=350; count < 550; ++count)
  {
    x = count;
    angle = radians(count);
    y =(4*(numOfWaves)/cbrt)*sin(angle*(numOfWaves/4));
    y = map(y, -1.5f, 1, -height/3, height/2);
    line(prevX, prevY, x, y);
    prevX= x;
    prevY=y;
  }
  prevX=350.0f;
  prevY=0.0f;
} 
public void mouseReleased() {

  locked = false;
}

class HScrollbar {
  int swidth, sheight;    // width and height of bar
  float xpos, ypos;       // x and y position of bar
  float spos, newspos;    // x position of slider
  float sposMin, sposMax; // max and min values of slider
  int loose;              // how loose/heavy
  boolean over;           // is the mouse over the slider?
  boolean locked;
  float ratio;

  HScrollbar (float xp, float yp, int sw, int sh, int l) {
    swidth = sw;
    sheight = sh;
    int widthtoheight = sw - sh;
    ratio = (float)sw / (float)widthtoheight;
    xpos = xp;
    ypos = yp-sheight/2;
    spos = xpos + swidth/2 - sheight/2;
    newspos = spos;
    sposMin = xpos;
    sposMax = xpos + swidth - sheight;
    loose = l;
  }

  public void update() {
    if (overEvent()) {
      over = true;
    } else {
      over = false;
    }
    if (mousePressed && over) {
      locked = true;
    }
    if (!mousePressed) {
      locked=false;
    }
    if (locked) {
      newspos = constrain(mouseX-sheight/2, sposMin, sposMax);
    }
    if (abs(newspos-spos)>1) {
      spos=spos + (newspos-spos)/loose;
    }
  }
  public float constrain(float val, float minv, float maxv) {
    return min(max(val, minv), maxv);
  }
  public boolean overEvent() {
    if (mouseX > xpos && mouseX < xpos+swidth && 
      mouseY>ypos && mouseY< ypos+sheight) {
      return true;
    } else 
    {
      return false;
    }
  }

  public void display() {

    noStroke();
    fill(204);
    rect(xpos, ypos, swidth, sheight);
    if (over || locked) {
      fill(70, 0, 0);
      numOfWaves=spos-100;
    } else {
      fill(102, 102, 102);
    }
    rect(spos, ypos, sheight, sheight);
  }
}
float coilx;
float coily;
int boxSize = 50;
boolean overBox = false;
boolean locked = false;
float xOffset = 0.0f; 
float yOffset = 0.0f; 
PImage coil;
public void mousePressed() {
  if(overBox) { 
    locked = true; 
     } else {
    locked = false;
    mouseX=pmouseX;
  }
  xOffset = mouseX-coilx; 
  //yOffset = mouseY-by; 

}

public void mouseDragged() {
  if(locked  && mouseX>425 && mouseX < (width-boxSize) ){
    coilx = mouseX-xOffset; 
   //d=0.5*(coilx-350);
//dcbrt=d*d*d;
  }else{
    mouseX=pmouseX;}
}



  public void settings() {  size(600, 600); }
  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "generatorv2" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}

It runs fine in processing but despite having the most current Java installed, it will not run either as a .jar file or the .exe file. How do I fix it.

Tagged:

Answers

  • Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code

    it will not run either as a .jar file or the .exe file

    If you click in the exe files, what does it do? Are you using external resources? What options did you click in the export window?

    Have you tried exporting simple applications? Do they work or do they have the same issues?

    Kf

  • Thank you for your reply kfrajer.

    Nothing at all happens when I click .exe. No I am not using external resources. tired all the options. First time, choose Presentation, stop button and embed java. Next time, did not choose presentation but stop button and embed java. Next time, Presentation, stop button and don't embed java. Next time no presentation, no stop button and dont embed java. Next time everything but embed java. I have the latest Java installed.

    Will try a simple application.

  • Exporting a simple application worked. I choose not to go full screen and to embed java. Will try breaking down code to find out which part is causing problem. This is my first serious attempt at programming. So thank you for your help. Trying to do something that my husband has been wanting to get up and running for his Physics students.

  • When I export using a simple application, none of the pictures are shown.

  • cro paddlewheel2 tap threecoil

    I have uploaded these images because of a thread I read. Hopefully, this might make it easier for someone to help with my problem

  • Great, you did good troubleshooting. It seems the problem is accessing the images when you export your application.

    Are your images in the data folder?

    Also from this post: https://forum.processing.org/two/discussion/20791/problem-export/p1 , add import java.*;

    Kf

  • kfrajer, you are a genius. I did not understand what people were meaning when they said to put the images in the data folder. For those newbies/dumbells like me - you need to put the images in the same folder as the executable file. Once I did that it worked like a charm. Physics students you have a new simulation assignment heading your way.

  • you need to put the images in the same folder as the executable file

    I don't think this is true. In a folder called data under the sketch folder is more usual. There's an 'add file' option in the menu that will do this for you.

  • @horseygym Thanks for sharing your answer

    @koogs When you export the application, the data folder is packed together or you just have to tag it along with your resources? In another post, @KevingWorkman provided details to pack all resources together. The processing's export and tips that I provided didn't touch any of these details. What is the standard practice? Do you know?

    Kf

  • edited March 2017

    In Linux in pretty sure the data folder is in the export as a folder. I'm not 100% sure that it's used though (there could be another copy bundled into a jar somewhere). (a quick tests shows that i can change the image in the data file and the code will use this new image without having to re-export)

    Windows is another thing though. (although that looks identical, with a data folder in the exported folder)

    (edits: have tested and corrected what i said before)

Sign In or Register to comment.