We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a Processing sketch that uses Java. It works fine when I run it through Processing. When I export it to application, it exports fine as well. However, when I open the application on my desktop, I get a grey screen. I tried adding the following because I saw it mentioned on a few forums:
public static void main (String[] args)
{
PApplet.main("thefinalcode");
}
And that just runs the application with no screen. There's no window at all. Here's my original sketch:
``` import twitter4j.conf.*; import twitter4j.*; import twitter4j.auth.*; import twitter4j.api.*; import java.util.*;
Twitter twitter; String searchString = "#food"; List tweets;
int currentTweet; String headline = "#food"; String footer; PFont f; float loc;
PImage img; PImage img1; PImage img2; PImage img3; PImage img4; PImage img5; PImage bgImg; PImage lpjLogo;
int clock = 0; int clockreset = 30;
long latestID = 0;
ArrayList uteri;
void setup() { //frameRate(5); size(displayWidth,displayHeight); // fill up the screen
f = createFont("ChunkFive Ex", 32, true);
loc = width;
img = loadImage("uteruswhite.png");
img1 = loadImage("uterus1.png");
img2 = loadImage("uterus2.png");
img3 = loadImage("uterus3.png");
img4 = loadImage("uterus4.png");
img5 = loadImage("uterus5.png");
lpjLogo = loadImage("lpjleague_bg_logo.png");
lpjLogo.resize(displayWidth, displayHeight);
// this is java's authentication:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("****");
cb.setOAuthConsumerSecret("****");
cb.setOAuthAccessToken("****");
cb.setOAuthAccessTokenSecret("****");
// this makes an authentication token with twitter
TwitterFactory tf = new TwitterFactory(cb.build());
// this is what you talk to to get info:
twitter = tf.getInstance();
getNewTweets(); // gets new tweets
currentTweet = 0; // restarts what tweet we're drawing
thread("refreshTweets");
background(lpjLogo);
uteri = new ArrayList<Uterus>();
}
void draw() { background(lpjLogo); //fill(255); textAlign(CENTER); textSize(140); text(headline,width/2,120);
textFont(f, 24);
if(tweets.size()>0 && currentTweet<tweets.size() && clock==0) // don't do anything unless there's something to do
{
Status status = tweets.get(currentTweet);
float x = random(width);
float y = random(120,height);
if(status.getId()>latestID) latestID = status.getId();
int pickNum = int(random(1,5));
uteri.add(new Uterus(x, y, pickNum, status.getText()));
currentTweet = currentTweet+1;
}
for(int i = 0;i<uteri.size();i++)
{
uteri.get(i).go();
if(uteri.get(i).killme) uteri.remove(i);
}
clock = (clock+1)%clockreset;
//saveFrame ("frames/####.png");
}
void getNewTweets() { try { Query query = new Query(searchString);
query.setSinceId(latestID);
QueryResult result = twitter.search(query);
tweets = result.getTweets();
}
catch (TwitterException te)
{
System.out.println("Failed to search tweets: " + te.getMessage());
System.exit(-1);
}
}
void refreshTweets() { while (true) { getNewTweets();
//println("Updated Tweets");
currentTweet = 0;
delay(5000);
}
} ```
I'm using Processing 2.2.1. Any advice as to what I'm doing wrong? I'm a novice so any help is greatly appreciated! Thank you!
Answers
@ssarkar7:: if it runs inside processing but shows only grey screen when exporting that could mean that you have to add some lib (probably .jar) in the export folder
You may be able to get more information to help you figure out the problem in the form of runtime errors reported to stdout if you can get the exported program to run via the cmd line.
On Windows (similar process on Linux / Mac) something like:
Start terminal: windows key + r,
cmd
, [enter]Point it at the exported app directory:
cd \
[enter]cd path\to\application.windows32
[enter]for example:
cd Users\Owner\Desktop\sketch_150925a\application.windows32
[enter]In the terminal window:
java -cp lib\* name_of_your_sketch
[enter]This should run your sketch and show any errors it produces in the terminal window.