Sketch path is not set

I’m using the Yahoo Weather Library

GitHub - delvedor/YahooWeatherProcessing: Yahoo Weather library for Processing
however I get an error whenever i try to create a weather object.
My code:

import processing.serial.*;

Serial dataPort;

String val;

//Settings
boolean use12Time = true;  //24-Hour time or 12-Hour time
int slide = 1;             //Starting slide
int totalSlides = 3;       //# of slides total
int slideTime = 3;         //Time on each slide (s)

//Timer
int savedTime;
int totalTime = slideTime * 1000;

//Yahoo weather
Weather weather = new Weather(23509325, "Celsius");

void setup() {
  size(200, 200);
  dataPort = new Serial(this, "COM5", 9600);
  savedTime = millis();
  while(weather.checkConnection() == false) {
    println("Refresh");
  }
}

void draw() {
  int passedTime = millis() - savedTime;
  if(passedTime > totalTime) {
    slide = (slide + 1) % totalSlides;
    savedTime = millis();
  }
  switch(slide) {
    case 1:
      if(use12Time) {
        if(hour() == 0) {
          dataPort.write("12:" + nf(minute(), 2) + " A" + '\n');
        } else if(1 <= hour() && hour() < 12) {
          dataPort.write(str(hour()) + ':' + nf(minute(), 2) + " A" + '\n');
        } else if(hour() == 12) {
          dataPort.write("12:" + str(minute()) + " P" + '\n');
        } else if(13 <= hour() && hour() < 24) {
          dataPort.write(str(hour() - 12) + ':' + nf(minute(), 2) + " P" + '\n');
        } else if(hour() == 24) {
          dataPort.write(str(hour()) + "12:" +nf(minute(), 2) + " A" + '\n');
        }
      } else {
        dataPort.write(str(hour()) + ':' + str(minute()) + '\n');
      }
    break;
    case 2:
      dataPort.write(str(month()) + '/' + str(day()) + '\n');
    break;
    case 3:
      
    break;
  }
}

The error:

The sketch path is not set.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at processing.core.PApplet.runSketch(PApplet.java:10741)
	at processing.core.PApplet.main(PApplet.java:10511)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at processing.core.PApplet.runSketch(PApplet.java:10735)
	... 1 more
Caused by: java.lang.RuntimeException: Files must be loaded inside setup() or after it has been called.
	at processing.core.PApplet.createInputRaw(PApplet.java:7039)
	at processing.core.PApplet.createInput(PApplet.java:7011)
	at processing.core.PApplet.createReader(PApplet.java:6817)
	at processing.core.PApplet.loadXML(PApplet.java:5930)
	at processing.core.PApplet.loadXML(PApplet.java:5920)
	at ProcessingTextClock$Weather.<init>(ProcessingTextClock.java:114)
	at ProcessingTextClock.<init>(ProcessingTextClock.java:39)
	... 6 more

I’m hoping that this works, however the library that I downloaded only has a .java file and a .pde file, so I can’t import the library with a .jar.

I believe the above error message is realted to this line:

I suggest you check the example that comes with the library as it shows how to use it properly.

Related to your last post, where did you downloaded the files from? Just to clarify, you need to isntall the Yahoo weather library from the Contribution Manager in the PDE. Did you do that?

Kf

Yup, I tried this and it worked, thanks!

1 Like

I had a similar error… The issue is in the line:
Weather weather = new Weather(23509325, “Celsius”);
been before the “setup”. To avoid the error you should do the following:

[…]
Weather weather;

void setup() {
weather = new Weather(23509325, “Celsius”);
[…]
}

yes, do as suggested,

BUT
do not use other peoples API code, use your own one.

also you should use the original yahoo api java example,
the mentioned GitHub - delvedor/YahooWeatherProcessing: Yahoo Weather library for Processing is from 2014.

but MOST: read
https://developer.yahoo.com/weather/

mportant EOL Notice: As of Thursday, Jan. 3, 2019, the weather.yahooapis.com and query.yahooapis.com for Yahoo Weather API will be retired.

1 Like