Problem accessing sounds in jar file

Hi,
I have made a program and packed it to a jar file.
Everything works fine in the IDE, so this is purely a matter of jar access.
The jar has 6 folders.
framework (which is one of my packages)
META-INF
sound (also my package)
sounds (my wav files for the program)
sprite (another package)
sprites (my graphics for the program).
I access the graphics in sprites, from a class in sprite and have no problem with it.
try {               
               URL url = this.getClass().getClassLoader().getResource(ref);               
               if (url == null) {
                    fail("Kan ikke finde ref: "+ref);
               sourceImage = ImageIO.read(url);
          } catch (IOException e) {
               fail("fejl ved load: "+ref);
          }The problem is accessing the wav file in the sounds folder from a class in the sound folder.
try{
               AudioInputStream stream = AudioSystem.getAudioInputStream(new File("Sounds/1999.wav"));
               AudioFormat format = stream.getFormat();
               DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat(),
                         ((int)stream.getFrameLength()*format.getFrameSize()));
               clip = (Clip) AudioSystem.getLine(info);
               clip.open(stream);
          }I have tried to use the class loader like this (instead of AudioSystem.getAudioInputStream) :
AudioInputStream stream = (AudioInputStream) this.getClass().getClassLoader().getResourceAsStream("sounds/1999.wav");          
but it didnt help.
Does anyone have any suggestione?
Please, if all you can do, is paste a link to the java API, save your energy. I have already looked and it was no help, as im still only a student of java.
I would like an actual suggestion, so i can see it work, then i can make work my way through the API from there.
Edited by: Mondariz on May 7, 2008 8:26 AM

Don't try to use a File object to access resources from the jar. You have a working process for accessing the sprites, just use the same process to access the sounds. Only not quite the same method, there's one method which returns a URL and a very similar method which returns an InputStream. I would post the link to the documentation but you asked for us to not do that. Anyway you seem to know where it is.

Similar Messages

  • Problems accessing class in JAR file [err = -4000]

    Hi, my setup is as follows ....
    I have a seq file that is accessing a Java class file, TestStandClient.java. something like
    public class TestStandClient
       public String test (String arg)
          String returnVal = "";
          try
             TestClass testClass = new TestClass ();
             returnVal = testClass .test (arg);
          catch (Exception e)
             returnVal = e .toString();
          return returnVal;
    TestClass.java is
    public class TestClass
       public String test (String arg)
          return arg + " : [Jar object has modified string]";
    Now. TestClass is in a seperate jar. When TestStandClient :: test  is called i get a -4000 error. From the readme in the Java example file it is described as ....
    Error
    reading returned string
    The
    string returned from Java was corrupt. Verify that the return type of the Java
    method is a string value.
    I have noticed if I take out the call to the object in the jar file then everything works ok.
    Could it be a classpath problem? the StartJVM has its classpath
    pointing at the folder where the jar is and also at where the
    TestStandClient class file is. I also set the classpath for the Java
    step to be the same (location of jar and class file)
    So, can someone inform me of what support TestStand has for java? Does it support communicating with a class file that itself depends on other JAR files? This is surely the case?
    thanks in advance

    Dear PCR Barry,
    I am afraid that I must agree with my colleague Kostas, who replied to your first teststand post. These are very tricky, indepth issues, and will require quite significant investigation. Furthermore, it will be very difficult for us to answer via the forums as we will likely need more input from yourself. As previously suggested, if you have a Standard Service Program (SSP), you can generate a Service Request by calling or e-mailing your local branch.
    Thank you for your time, and I am sorry that I have been unable to help you further,
    Best wishes,
    Rich R
    Applications Engineer
    National Instruments UK & Ireland

  • Problems accessing resources in JAR Files

    Hi all,
    i'm using a third party software which isb trying to access a configuration file (xml file) residing inside its jar files.
    Without Webstart there are now problems, when deploying the software with Webstart, the resources could not be found.
    The software installs an streamhandler which handles all access to its resources.
    When this handler is instantiated, a Classloader is provided via Thread.currentThread()..getContextClassLoader().
    As i can see this classloader (and only this-) instance is used when resources are acessed.
    The classloader instance seems to me to be the correct one of type ...JNLPClassLoader.
    As i figured out the classloader is able to acess the resource In the Moment when the Handler is instantiated.
    But later in the code (inside of the Handler) any call of getResource() with identical parameter for the resource name fails.
    The classloader instance is the same as in the previous calls (which i have added for debug).
    The Handler class resides in a different jar file as the resource, but i have also tried to put them in one jar file achieving the same result.
    Has anyone an idea what is going wrong ?
    The application has "all-permissions" granted, but suprisingly i'm receiving an security exception when trying to call Class.getProtectactionDomain() inside of the Handler class.
    Could it be a security problem ?
    Thank you.
    Andrej
    Message was edited by:
    a.rippich
    Message was edited by:
    a.rippich

    Dear PCR Barry,
    I am afraid that I must agree with my colleague Kostas, who replied to your first teststand post. These are very tricky, indepth issues, and will require quite significant investigation. Furthermore, it will be very difficult for us to answer via the forums as we will likely need more input from yourself. As previously suggested, if you have a Standard Service Program (SSP), you can generate a Service Request by calling or e-mailing your local branch.
    Thank you for your time, and I am sorry that I have been unable to help you further,
    Best wishes,
    Rich R
    Applications Engineer
    National Instruments UK & Ireland

  • Problem accessing class in jar file

    Hello. I am trying to create a jar file from my already compiled classes. I have around 5 packages, and my programs' entry point is in one of the packages, we'll call package A. Each package has its own purpose and package A calls any needed package to perform their task. This works well when I compile, run and all. However, when I create a jar file, it only works with the local package and any calls to another package do not work. How can I get around this? any help will be appreciated

    This is the output..
    05/05/2010  10:19 AM        10,946,787 MYJAR.jar
                   1 File(s)     10,946,787 bytes
                   0 Dir(s)   1,434,251,264 bytes freeMy manifest file contains
    Manifest-Version: 1.0
    Class-Path: .
    Main-Class: Login.loginMain
    AndrewThompson64 wrote:Is the code [swallowing exceptions|http://pscode.org/javafaq.html#stacktrace] at any point?
    Nope..
    AndrewThompson64 wrote:
    How do you know that if there is absolutely no error output?The when I ran the code from my compiler, it has no errors, and it works smoothly. I have used a JAR for a single package program before and it worked well but this multiple package program is giving me the problem and I don't want to put all the files in a single package

  • Problem accessing Application Ejb Jar files from Apache Axis jars

    I have deployed an EAR application, with a structure as shown below,
    MyApp.ear
    |____ MyApp_Ejb.jar
    |____ axis.war
    |_____ WEB-INF
    |_____ lib (This contains all axis specific jars)
    The application deploys just fine. But when i goto happyaxis.jsp and try to view all the web services that have been deployed. I get an exception "No provider type matches QName '{http://xml.apache.org/axis/wsdd/providers/java}SDL".
    Here SDL is a custom provider that i have written and all the required files for the provider are available in MyApp_Ejb.jar.
    I do not get as to why the axis.jar is not able to find classes in MyApp_Ejb.ear, when both these are in the same ear.
    Now i know i can add a utility jar to a war files classpath by adding a classpath line in the War file MANIFEST.MF. But since MyApp_Ejb.jar is defined as a Web Module this solution too doesnt help.
    Separating the provider related files from MyApp_Ejb.jar is not possible since there is too much dependance of other files within that jar.
    So i am looking for a solution where in i can continue to have MyApp_Ejb.jar as my ejb module as well as the axis related jars can find the required classes within MyApp_Ejb.jar. some way of sharing the ejb jar across to axis jars.
    Thanks in advance.
    Vicky

    I have deployed an EAR application, with a structure as shown below,
    MyApp.ear
    |____ MyApp_Ejb.jar
    |____ axis.war
    |_____ WEB-INF
    |_____ lib (This contains all axis specific jars)
    The application deploys just fine. But when i goto happyaxis.jsp and try to view all the web services that have been deployed. I get an exception "No provider type matches QName '{http://xml.apache.org/axis/wsdd/providers/java}SDL".
    Here SDL is a custom provider that i have written and all the required files for the provider are available in MyApp_Ejb.jar.
    I do not get as to why the axis.jar is not able to find classes in MyApp_Ejb.ear, when both these are in the same ear.
    Now i know i can add a utility jar to a war files classpath by adding a classpath line in the War file MANIFEST.MF. But since MyApp_Ejb.jar is defined as a Web Module this solution too doesnt help.
    Separating the provider related files from MyApp_Ejb.jar is not possible since there is too much dependance of other files within that jar.
    So i am looking for a solution where in i can continue to have MyApp_Ejb.jar as my ejb module as well as the axis related jars can find the required classes within MyApp_Ejb.jar. some way of sharing the ejb jar across to axis jars.
    Thanks in advance.
    Vicky

  • How to access additional supporting jar files from EJB JAR?

    Hi,
    How can we access additional supporting jar files as part of my EJB JAR .
    I don't want to keep them in the top level because other EJB JAR files also has
    the same jar files(code in the classes in the jar is slightly different)
    can I keep the additional jar files in my EJB JAR?
    Thanks
    NLB

    Include the supporting jar files in the Ejb jar file.
    Specifiy the jar files in the Ejb jar manifest file.
    Manifest-Version: 1.0 [CRLF]
    Class-Path: utility.jar [CRLF]
    thanks,
    Deepak
    "NLB" <[email protected]> wrote:
    >
    Hi,
    How can we access additional supporting jar files as part of my EJB JAR
    I don't want to keep them in the top level because other EJB JAR files
    also has
    the same jar files(code in the classes in the jar is slightly different)
    can I keep the additional jar files in my EJB JAR?
    Thanks
    NLB

  • How to access the database jar file using the derby 10.2.1.6 database ?

    Hi,
    How to access the database jar file using the derby 10.2.1.6 database ?
    I have used like below. And i am getting the following the error:
    "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.apache.derby.jdbc.EmbeddedDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)"
    My context.xml file looks like this:
    <Context crossContext="true">
    <Resource name="jdbc/derby" auth="Container"
    type="javax.sql.DataSource" driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
    url="jdbc:derby:jar(\CalypsoDemo\database.jar)samples"
    username="xxx" password="xxx" maxActive="20" maxIdle="10"
    maxWait="-1"/>
    </Context>
    What could be the reason.?
    Any suggestions will be appriciated.
    Thanks in Advance,
    Gana.

    ya, I have restarted. Can you please tell me whether the path which i am giving is right or not in the context file?
    Thanks,
    Gana.

  • HT204382 Hi, Ive just got myself a Macbook Pro, and Im having problems with sound on movie files. The format is wmv and they play OK on a windows 7 laptop, and Im trying to play them now on the MAC. The picture is OK , but no sound. I have Flip4Mac - no d

    Hi, Ive just got myself a Macbook Pro, and Im having problems with sound on movie files. The format is wmv and they play OK on a windows 7 laptop, and Im trying to play them now on the MAC. The picture is OK , but no sound. I have Flip4Mac - no diference

    Download and install the free VLC for Mac - that should work:
    http://www.videolan.org/vlc/download-macosx.html

  • Problem loading Applets from Jar files on 64 bit machine

    I am developing an applet (extends Applet but uses swing components) using JDK 1.6 (Though these problems still happen in JDK 1.7) and I am unable to get the applet to load on a 64 bit machine in most cases. The web server(s) are running on localhost and I am connecting on the same machine using a local network ip address (such as 192.168.*.*)
    Below are all of my test results. Can someone provide a suggestion for repairing this? The Windows Server machine is a clients computer I access to it via remote desktop but I can't do much with it though I do have administrator rights. The Windows 7 machine is my development platform so I have been able to do extensive testing on it.
    This problem is presenting in the following environments when trying to load an applet from JAR files in a HTML document using the Applet or Object tag.
    Windows Server 2008 (Intel Chipset)
    Tested Browsers:
    Internet Explorer 9 (32 bit) - Shows it is blocked by default then simply shows an x when loaded from a web page, same result when loading from local drive.
    Windows 7 Home Premium (AMD Chipset)
    Tested Browsers:
    Firefox 6.0.1 (32 bit) - Java logo shows with spinner, after a few minutes there is finally an error that a class in the jar was not found
    Internet Explorer 9 (32 bit) - Java logo shows with spinner, after a few minutes there is finally an error that a class in the jar was not found
    Internet Explorer 9 (64 bit) - Java logo shows with spinner and most of the windows desktop manager freezes, keyboard is the only thing that responds so you can alt-tab to another app to regain control of the desktop.
    Chrome (32 bit) - Java logo shows with spinner, after a few minutes there is finally an error that a class in the jar was not found
    The only way I have been able to get a Java applet to run on a 64 bit machine are the following ways.
    Firefox 9 nightly (64 bit) works perfectly! Go Firefox!
    Internet Explorer 9 (32 bit) loading directly from drive (c:\...)
    Chrome (32 bit) loading directly from drive (c:\...)
    Firefox 6.0.1 (32 bit) loading directly from drive (c:\....)
    Can someone please help! I've been fighting with this bug for over a week and I can't find anything that will solve it, I have noticed that in some cases if my jar has very little code in it than it will run on the server, but the minute I start adding things to it the jar won't load anymore.

    jschell wrote:
    rritoch wrote:
    I am developing an applet (extends Applet but uses swing components) using JDK 1.6 (Though these problems still happen in JDK 1.7) and I am unable to get the applet to load on a 64 bit machine in most cases.
    To clarify...
    1. You have tried it on 32 bit machine? Exactly which OS?I tested this on Windows Vista Business which is in 32 bit mode and the applets run without any problems
    >
    2. Your only 64 bit tests have involved 2008/Win7?
    If so then I would suspect something with windows not java. Probably permissions.
    The web server(s) are running on localhost and I am connecting on the same machine using a local network ip address (such as 192.168.*.*)
    Yes, I haven't tried running the jars on other operating systems.
    >
    I don't understand that. If you are running on localhost then you should connect to localhost. If running on an IP then you should connect to that. Perhaps you meant that you have tested using both of those?I'm testing using the lan ip address but I'm connecting from the same machine. I've tried localhost and that didn't work so I tried lan ip since that will likely have a different java security context than localhost. At first I was blaming the IIS server but I downloaded the jar directly and using HTTP fox was able to verify that the jar is being sent with the correct mime-type and that the server can upload the jar file without a problem. This leaves me to believe the problem is with Java.

  • Problem with addition of jar file to DC

    Hi WDers,
    I have a DC of type WD.
    I'm trying to add com.sap.security.api.jar file to this component so that I can get IUser and work on it.
    I have added this security jar file as an External jar file to the DC. But whenever I try to DC->Build, the jar entry is going away. So the Build is failing.
    Can you kindly let me know why this is happening?
    Or is there any other way to add a jar file so that I can use the IUser interface in my view?
    Thanks in Advance
    RK

    Hello,
    Add the Standard DC "com.sap.security.api.sda" from the SAP-JEE. This ahould solve the problem.
    To do that follow the steps:
    1. Go to the "DC Metadata" option available under the DC.
    2. Go to "Used DCs" and choose "Add used DCs" from the context menu which appears on a right click at the Used Dcs option.
    3.Select "com.sap.security.api.sda" under SAP-JEE and choose finish.
    4. Build the DC to gain access to the IUser and other related classes.
    Bala.

  • How to access picture in jar file?

    i,ve made a jar file containing folder named frame\\data
    and the folder data containing picture and sound
    and i want to call\access the picture and the sound to make them appear to the user how?
    this is my code
    import java.io.*;
    import java.net.URL;
    import java.awt.*;
    import javax.swing.ImageIcon;
    import javax.swing.*;
    import javax.swing.JOptionPane;
    import javax.swing.JButton;
    import javax.swing.AbstractButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.sound.sampled.*;
    import java.awt.event.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
      public class MyFrame extends JFrame 
    ImageIcon img =new ImageIcon("src\\frame\\data\\heart7.png");
    JButton btn=new JButton("Press Me", img);
      MyInner inner;
        MyInner4 inner4;
          MyFrame ()
            setupGUI();
        private void setupGUI()
           JFrame f =new JFrame();
        //   f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
           f.setTitle("Window Event");
            f.setSize(550,350);
            f.setResizable(false);
            f.setLayout(new BorderLayout());
            f.add("Center",btn);
              btn.setVerticalTextPosition(AbstractButton.BOTTOM);
              btn.setHorizontalTextPosition(AbstractButton.CENTER);
            f.setVisible(true);
             inner=new  MyInner();
             inner4=new  MyInner4();
             f.addWindowListener(inner);
             f.addWindowListener(inner4);
             class MyInner extends WindowAdapter
            public void windowClosing(WindowEvent ee)
                Toolkit tool = Toolkit.getDefaultToolkit();
                tool.beep();
                JOptionPane.showMessageDialog(null, "Better Work!","Bye Bye",JOptionPane.INFORMATION_MESSAGE,img);
               // JOptionPane.showMessageDialog(null, "Text", "Title", JOptionPane.Type, icon);
                System.exit(0);
            class MyInner4 extends WindowAdapter
          public void   windowOpened(WindowEvent ex)
             try {
            // From file
            AudioInputStream stream = AudioSystem.getAudioInputStream(new File("src\\frame\\data\\BraveHeart.wav"));
            // From URL
            //stream = AudioSystem.getAudioInputStream(new URL("http://hostname/audiofile"));
            // At present, ALAW and ULAW encodings must be converted
            // to PCM_SIGNED before it can be played
            AudioFormat format = stream.getFormat();
            if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
                format = new AudioFormat(
                        AudioFormat.Encoding.PCM_SIGNED,
                        format.getSampleRate(),
                        format.getSampleSizeInBits()*2,
                        format.getChannels(),
                        format.getFrameSize()*2,
                        format.getFrameRate(),
                        true);        // big endian
                stream = AudioSystem.getAudioInputStream(format, stream);
            // Create the clip
            DataLine.Info info = new DataLine.Info(
                Clip.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
            Clip clip = (Clip) AudioSystem.getLine(info);
            // This method does not return until the audio file is completely loaded
            clip.open(stream);
            // Start playing
            clip.start();
            // Play and loop forever
        clip.loop(Clip.LOOP_CONTINUOUSLY);
        /* Play and repeat for a certain number of times
        int numberOfPlays = 3;
        clip.loop(numberOfPlays-1);
         catch (IOException e) {
        } catch (LineUnavailableException e) {
        } catch (UnsupportedAudioFileException e) {
          public  static void main(String[]args)
             MyFrame frame=new MyFrame ();
    }

    Instead of doing like this,
    ImageIcon img =new ImageIcon("src\\frame\\data\\heart7.png");
    JButton btn=new JButton("Press Me", img); use this code,and then prepare the jar
    try{
    URL pathShell = null;
    Object dummy = new Object(){
         public String toString() { return super.toString(); }
    ClassLoader cl = dummy.getClass().getClassLoader();
    pathShell  = cl.getResource("src\\frame\\data\\heart7.png");
    image = new ImageIcon(pathShell);
    JButton btn=new JButton("Press Me", imgage);
    catch (Exception e) {}

  • Accessing ressources in jar file

    Hi,
    I need some help with jar files, please.
    The concept of jar files is quite new to me and I din't fully unterstand it yet I guess...
    I'm loading an image by
    ImageIcon image = new ImageIcon("image.gif");
    now I'd like to pack that image into a jar file, for simplifying reasons when using more files, which is not the problem, so far.
    But how can I access that file then in my java programm?
    Do I have to use the JarFile.getInputStream() method or what?
    Is there no 'easier' way, avoiding Streams and Readers?
    Can I hand over the JarEntry of my gif file to the ImageIcon constructor
    somehow instead of the file?
    Thanks for help..

    I guess you've set me on the right course, but I am
    afraid I don't really understand the concept of those
    class loaders, either.
    I read the part on jar files and extensions in the
    java tutorial(and therefore on class loaders, too),
    but I still don' get it.JAR Files and classloaders are two different concepts. The JAR file is merely a packaging method for Java code. Classloaders on the other hand, are the way the JVM finds the code classes. All a classloader does is load binary data from somewhere and pass it to the JVM for execution. See http://java.sun.com/j2se/1.4/docs/api/java/lang/ClassLoader.html for more info.
    The relevant code part we're talking about here is
    used in a class extending JPanel , so thats what you
    get by performing getClass(), the running instance of
    a JPanel subclass.
    but obviousely there is no getResource() method in
    that type of class.Really? http://java.sun.com/j2se/1.4/docs/api/java/lang/Class.html#getResource(java.lang.String)
    Of course, Object.getClass().getResource() is just a convienence method for Object.getClass().getClassLoader().getResource(). Just as the ClassLoader can load the binary data that creates a Class object that lends itself to the execution of the Object you're loading, it can load other forms of binary data from the same location.
    what I don't understand is: where does this method
    come frome? do I have to add somehow a classlistener
    instance to my class? or add an implementation in the
    code of my class, providing a getResource method? A Class object (See http://java.sun.com/j2se/1.4/docs/api/java/lang/Class.html) is merely a "wrapper" object that represents the running code. It exposes the methods and fields for access. Normally Class is used behind the scenes, but it can be used to execute dynamically loaded code.
    You don't need to "add" a classloader. A classloader loaded the code that you are running. When it loads the class, it stamps it with its signature so that you know who loaded it.
    I guess you see now I really have no idea how the
    classloader system works ;)
    (and believe me I'm not asking dumb questions berfore
    trying to solve the prob by myself....)
    Thanks for any additional helpNo prob. :-)

  • Problems deploying sounds with jar/game

    I've almost finished my game, for as far as software can ever be finished. Now I've troubles creating a jar file that contains all of the game's resources. Within my IDE (Eclipse) the game finds & plays .wav files correctly using:
    for(int i = 0; i< names.length;i++){     
         ais = null;
         cl = this.getClass().getClassLoader();               
         ais = AudioSystem.getAudioInputStream(cl.getResourceAsStream("sound/" + names));
         clips[i] = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class, ais.getFormat()));
         clips[i].open(ais);
    But when I start the game using the jar file I get the following exception:
    java.lang.NullPointerException
            at java.io.FilterInputStream.mark(FilterInputStream.java:179)
            at com.sun.media.sound.WaveFileReader.getAudioFileFormat(WaveFileReader.
    java:94)
            at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader
    .java:237)
            at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:
    680)
            at field.TestFrame.initSoundContext(TestFrame.java:657)
            at field.TestFrame.init(TestFrame.java:157)
            at field.TestFrame.<init>(TestFrame.java:112)
            at field.TestFrame.main(TestFrame.java:117)
    Exception in thread "main" java.lang.NullPointerException
            at field.TestFrame.initSoundContext(TestFrame.java:672)
            at field.TestFrame.init(TestFrame.java:157)
            at field.TestFrame.<init>(TestFrame.java:112)
            at field.TestFrame.main(TestFrame.java:117)Yes, I've made sure the .wav files are in the jar ;)
    Does anyone know what the problem could be? Help ?-)
    Greetings
    Coen

    Thank you for your reply, but I didn't get any further. I tried you code, but got another error.I use the same code (as described at the top) to load my images, but no problems there (?) I'll try to fix the problem myself, but suggestions would be very helpfull :)
    Exception:
    java.io.IOException: mark/reset not supported
    at java.io.InputStream.reset(InputStream.java:329)
    at java.io.FilterInputStream.reset(FilterInputStream.java:204)
    at com.sun.media.sound.WaveFileReader.getAudioFileFormat(WaveFileReader.
    java:128)
    at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader
    .java:237)
    at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:
    680)
    at field.TestFrame.initSoundContext(TestFrame.java:658)
    at field.TestFrame.init(TestFrame.java:157)
    at field.TestFrame.<init>(TestFrame.java:112)
    at field.TestFrame.main(TestFrame.java:117)
    Exception in thread "main" java.lang.NullPointerException
    at field.TestFrame.initSoundContext(TestFrame.java:673)
    at field.TestFrame.init(TestFrame.java:157)
    at field.TestFrame.<init>(TestFrame.java:112)
    at field.TestFrame.main(TestFrame.java:117)
    Thanks in advance for any help offered :)

  • STRANGE problem with sound in SWF files...Please help if you know how...

    Hello,
         Okay, so, I recently learned how to use Adobe InDesign to create a book.  there is a lot a still don't know.  When I export my document as a SWF file, it works great and has sound and animations where it should.  However, if I move that SWF to a new location, such as my desktop or uploading it to an e-mail, it looses all the sound information.  To add sound to each page, I added a hidden object to each page that was the sound file so that I could attach it to a button.  It seems that it is loosing that sound file if I move it to a new location.  Any ideas or solutions?

    UPDATE:  I have learned that my problem is related to a "resourse folder" which must go wherever the file goes in order for it to have sound.  This is a bit inconvinient for me, as my client is computer illiterate.  I really want to find a way to just embed the sound into a file that you can just open and play.  To the best of my knowlege, SWF format is the only format that allows for the page turning animation.  Does anyone know a way to embed the sound into the SWF file or am I SOL here?

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

Maybe you are looking for