I have a program with war file sounds. The sounds are playing perfectly when I ran the program in eclipse but in the jar file, I get a FileNotFoundException. This is how I added the war files:
public class MainClass implements Serializable{
private static final long serialVersionUID = 1L;
public static Library library;
public static void main(String[] args)
{
try {
loading();
} catch (IOException e2) {
e2.printStackTrace();
}
if(library == null) {
library = Library.getInstance();
}
try
{
FileInputStream button4 = new FileInputStream("sound/welcome.wav");
AudioStream b4 = new AudioStream(button4);
AudioPlayer.player.start(b4);
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(null,"File not found");
}
catch(IOException eio)
{
JOptionPane.showMessageDialog(null,"Sound Problems");
}
Login login = new Login();
login.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
login.setVisible(true);
login.setSize(600, 400);
}
}
The war file is in the same folder as my project. Do I need to add the file in different way? Here is how the war file is located in the project: