I was following a tutorial to create a weather app using a Weather Library.When i tried to display the temperature of a certain place i got an error.I think there must have been a problem due to updation of the library.I am going to share the code, video tutorial link and the error so that you can exactly point out the mistake.
CODE:
public class HomeGUI extends javax.swing.JFrame {
public HomeGUI() {
initComponents();
getWeather();
}
private void getWeather() {
WeatherDoc doc=new WeatherDoc("29226594","c");
WeatherDisplay disp=new WeatherDisplay();
System.out.println(disp.getTemperature());
}
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception ex) {
java.util.logging.Logger.getLogger(HomeGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new HomeGUI().setVisible(true);
}
});
}
...
}
error:
run:
Mar 21, 2018 11:59:48 PM com.teknikindustries.yahooweather.WeatherDoc <init>
null
SEVERE: null
java.net.UnknownHostException: xml.weather.yahoo.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
...
BUILD SUCCESSFUL (total time: 10 seconds)
Any help would be appreciated.