Accessing Video File within .Jar

Ok, I am creating a project where I am using JMF to display several pre-created videos. The finished project is going to be placed on a cd and submitted in a contest. Because of this, I am compiling the finished project into an executable .jar file. From my previous experiences, I have found that accessing files inside a jar is much more complex than accessing just any old file. The only way I have found to successfully access files inside a jar is through InputStreams (opposed to URLs). This is where my issues begin.
I have been searching throughout the internet for the past 2 days trying to find any way to create a Player using a type of InputStream. This doesnt seem to be possible the way it is set up. My obsticle here seems to be getting the Manager to realize the File. Here is what I've tried and the errors I got:
File -- NoPlayerException -- Expected. When creating a file, it doesnt know to look inside the jar for the file, but to the location of the jar instead. Perhaps there is a way to tell URL to look for the file inside the jar. If so, please tell me how.
File movie = new File("video1.mpeg");
JOptionPane.showMessageDialog(null, "File: " + movie + "\n URL: " + movie.toURL() + "\n URI: " + movie.toURI() + "\n URL Parsed URI: " + movie.toURI().toURL(), "Error", JOptionPane.ERROR_MESSAGE); //JOptionPane used to display background information while program is running after compiled in .jar
MediaPanel mediaPanel = new MediaPanel(movie.getURL());
InputStream -- Compiling Error -- So my primary method of getting Files inside jars are out the window since there is no way to get the URL of InputStreams.
InputStream movie = getClass().getResourceAsStream("video1.mpeg");
MediaPanel mediaPanel = new MediaPanel(movie);
Creating MediaLocator to file location -- java.net.MalformedURLException: no protocol: video1.mpeg -- I assume that basically means I'm screwed.
MediaLocator movie = new MediaLocator("video1.mpeg");
JOptionPane.showMessageDialog(null, "File: " + movie + "\n URL: " + movie.getURL(), "Error", JOptionPane.ERROR_MESSAGE);
MediaPanel mediaPanel = new MediaPanel(movie.getURL());
Using URL to get into .jar -- NoPlayerException -- No clue about this one. Just tried this a minute ago.
URL movie = HannibalProject.class.getResource("video1.mpeg");
JOptionPane.showMessageDialog(null, "URL: " + movie, "Error", JOptionPane.ERROR_MESSAGE); // Displays "URL: jar:file:/G:/Latin/HannibalProject.jar!/video1.mpeg" I do not know if this is correct or not, perhaps someone could tell me.
MediaPanel mediaPanel = new MediaPanel(movie);If anyone can help me with this, I will be GREATLY appreciative. If anyone needs more information, additional code snippets, ect. please ask and I'll provide what is needed to help me.
Edited by: Aussiemcgr on Jan 10, 2010 7:03 PM

And there arises the pain-in-the-ass that is not yet clear to me. For this particular thing, it needs to be an application, not an applet. Which means I have to make it an executable (alternative might be a .bat, havent played with those for anything other than scripts) instead of something embedded. For whatever reasons, this is the efficiency of the school system or whatever the hell it is.
The simple fact in all of this is that I have no information about the computer this is going to be ran on. Effectively, I am doing this all in the dark right now because I have been given NO guarantee that the computer(s) I attempt to run this on will even have the Java Virtual Environment on it. And, unfortunately, I have no way of finding any of this out because the Computer Program category of these things are not yet been taken seriously so preparation for judging is a last-minute thing.
Basically, I am wanting to do this with the least amount of possibilities for Murphy's Law (which means I probably shouldnt be using JMF to begin with, but I hate that incomplete feeling) to happen. For the dark abyss I am traveling into, I'm wanting to leave as little external dependencies as possible. For applets, I have to assume that the computer has some sort of browser (sounds stupid, but it is the school system). Not to mention I've designed it from the ground up to work as an application, instead of an applet (roughly 20 hours of work so far, including text research and coding).
The contest is Jan 30 so the date is approaching real quick. Quite honestly, the more I am looking at it, the more I am starting to consider getting rid of the videos altogether since I am pretty much done with the project with the exception of that. I would have 9 videos total (made only 1 to make sure it would work before making the other 8). The videos itself would only add an additional flair at best, and pretty much guarantee the 1st place for me. My teacher thinks my program's current capabilities, with just a mouse hover and mouse clicking interface with some animated gifs that allows access to several neatly displayed texts, would probably win me first place. However I feel I would go crazy if I actually had legitimate competition for once and lost because I didnt include this damn multimedia. Not to mention I want to include this on my portfolio in the somewhat distant future (along with my Poker Program I finished last month)...I dont know where I'm going with this...

Similar Messages

  • Error while trying access video file in KM Content

    Hi All,
    I are having an issue while trying to access video files located in KM.
    When we try to access the file we get and error : getting content of document failed: /usr/sap/pa8/SYS/global/config/cm/ep/content/73/47/6176162974773.CONTENT (no such file or directory)
    The file is a .wmv file and has a size of 49 MB. Whereas some other files of size 34 MB opens up with no issues.
    This is happening on production environment but the same works fine in pre prod environment.
    I am trying to access the file from Content Administration -> KM Content
    This issue is happening for multiple files of larger size in that environment. Please suggest how to rectify the issue.
    Regards,
    Somnath.

    Hi Somnath
    The issue you are facing is dealt in the below Note. Kindly check if you are at the specified SP and
    Patch level as per your Portal Version according to the note or not.
    1849886 - Content could be lost when using DBFS repository
    Regards
    Santarshi Samanta

  • How can I access video file from sd card on ipad2?

    How can I access video file from sd card on ipad2?

    Your iPad 2 will see the video if:
    It's in a DCIM folder on the top level of the card (which is how most cameras do it)
    It's name is 8 characters, no more, no less (CKDI9483 for example)
    It's a format that the iPad will play
    I've made mp4's of things, folderized them right and named them 'right' and can transfer them to my iPad, so you can use a computer to make the files conform to what the iPad will see.

  • How to use database file within jar archive

    Hi. I'm quite new in Java programming, and I'm wondering if what I did makes sense or not.
    In my applet I'm using a MS Access Database file, which is contained in the same Jar Archive like the Applet class file. I tried and tried to use this Database file directly but it wouldn't work. Than I read in some other forum that it is not possible to use the database file directly within the archive. First question: Is that true?
    Than I desided to extract the DB file in the init() method of my applet to the default temporary foulder. When the program is closed I use the destroy() method to delete it again. Everything works well now. But is this the typical way this is done?
    Thanks for help!

    Hi,
    here is the code which extracts the database file out of the jar archive (the same archive in which the class file is):
    //get the user temporary folder
    File TempFolder = new File(System.getProperty("java.io.tmpdir"));
    //create (empty) db file
    efile = new File(TempFolder, "steelSections.mdb");
    // if database file is not yet extracted
    if (!efile.exists()) {
    //get an input stream for the database file
    InputStream in = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(
    "FaST/db/steelSections.mdb"));
    //create an output stream for the db file on the file system
    OutputStream out = new BufferedOutputStream(new FileOutputStream(efile));
    //-Buffer to copy the data
    byte[] buffer = new byte[2048]; //buffer to copy the binary
    for (;;) {
    int nBytes = in.read(buffer); //read data
    if (nBytes <= 0)
    break; //no more data to read
    out.write(buffer, 0, nBytes); //write data
    out.flush(); //close out and in streams
    out.close();
    in.close();
    If you have the db file in an other jar archive file you need a referenze to the entry in the other jar archive. I'm not sure how to get this, but I'm sure you fill find a solution by searching in this forum...
    Good luck!

  • Accessing a File within a zip, which was archived using Applet Tag

    Hi,
    Could Any one please tell me, How to Access a File from within an Applet. The File resides inside a zip which was Archived using <Applet> Tag.
    Actually, I want to write an application which runs both online and offline. So I have chosen Applet and All the files Which I need are zipped and is Archived through <Applet ARCHIVE="example.zip">.
    Now I want to access those XML files which are inside example.zip from my Applet.
    How can I do that?
    I think I will get security Exception.
    How to get rid of this security Exception.
    Kindly Answer soon.......
    It's very urgent.
    Thanking you,
    KumudaRaj

    Did you already try signing a jarfile? If no ->>
    You can call a class inside a jar-file within the applet.
    if this class should be able to acces files the jarfile
    first has to be signed. to do this, you must generate a key.
    the complete work:
    1. write your applet
    2. write a html-page with following code:
    <APPLET code="guestbook.class" archive="guestbook.jar" width=600 height=400></APPLET>
    3. make a zip-file with the guestbook.class, guestbook.form, guestbook$1.class, guestbook$... and rename it to guestbook.jar
    4. in the console type:
    keytool -genkey -alias YOURNAME
    5. sign the key to your jarfile with:
    jarsigner guestbook.jar YOURNAME
    6. try the applet. a warning should appear which you have to answer
    with YES then it should work
    my trouble is that i cant acces files anyway because right now i don�t
    alreadv have the clue to get the right (absolute?) path for the file. means i get an ioexception because the applet cant find the file :-((
    does anyone know how to solve this problem then? my code is:
    FileReader Stream = new FileReader("/members/Ui97u8g4f6b89mj90kh5gbr4ecf6KXC4/guestbook.txt");
    ...

  • File within jar

    I created a jar file for my application using eclipse
    within my project i have some file my application uses as images
    i have a issue with the path to write to access those files
    currently although all those files are already in the jar i have to create a folder duplicate those files and copy the jar in that folder to be able to use my resources.
    to be more specific assuming i have
    Package1
    Package1.class1
    Package2
    Package2.image
    what will be the path to write in class1 to open the image file?
    I print out the directory while the program is running and it is the directory in which the jar file is
    so i use this path
    ./myproject.jar/package2/images
    in class1 code but it can not find the file(no such file error)
    My question is what is the path to write in class1 to open a file located in package 2
    Thanks

    The relative path to an image file or other resource file is always in relation to the current class file that is executing.
    So your class in Package1 cannot have access to an image in Package2.
    It is just impossible.
    The only way to do this is to move your image files at a location relative to the class that requires the files within Package1.

  • Access XML File in JAR file

    Hi I am trying to access a XML file which is present within a JAR file. The xml file needs to be accessed from class files within the jar. The class files within the jar use the xml file as a config file.
    The jar is used by external programs during their runtime.
    Can someone help me with some info on where I can begin.
    Thanks

    DrClap, Thank you very much. It works. You certainly are a qualified Dr.
    Regards

  • Can't access class files in jar file

    I'm running Eclipse and trying to access class files in a jar file from source. I have added the jar file through Properties/Java Build Path/Add External JARs... but the class files are not visible from my source code. Any ideas what is happening?
    Thanks!

    Depends what you mean by "visible." Are you getting a ClassNotFoundException? If so, your JAR isn't in your runtime CLASSPATH. You should be able to solve that (in Eclipse) by by modifying your project classpath.
    If "visible" means your code is usng a ZIP class to peek inside the JAR & it's not working, best bet is to re-study the ZIP class Javadocs & examine the error messages carefully.
    If this doesn't solve the problem, please provide more details & the specific error message/stack trace you're getting.

  • Accessing resource files inside Jar using Fat Jar Eclipse plugin

    Hi,
    I want to develop single JAR file that uses a set of other JAR libraries. I am using Fat Jar Eclipse plugin. It works fine. However, I have problem to access resources files (i.e. rdf file) using relative path from my classes. Is there any idea how can I pack, set classpath and use relative path in order to make it works.
    Thanks
    Zoran

    I have solved this problem. The problem was in a way how I have trying to access it. It should be like:
    URL fileURL = this.getClass().getResource("resource/myFile.rdf");
    Zoran

  • Static method to read text file within JAR.

    I've a small problem. I've got my JAR file stuff working great, so I thought I'd give a go to running it via WebStart. Through a little research, I've found that if you're distributing your application via WebStart, you need to pack up everything in a JAR file. This is no problem for the JDBC drivers, because its already in a JAR, so I should be able to distribute that fine.
    I've managed to digitally sign my application JAR and have a preliminary (i.e. untested) JNLP file set up.
    My problem is, my application gets its available data sources from an external text file. I've already written my own file I/O class which I use in my "commonfiles" package to read in a text file and return it as an array with each element holding a line from the text file. This class is basically just a bunch of static methods.
    So instead of rewriting this, I thought I'd just add a boolean flag to this method to state whether to load this file from the external file system or the JAR file. I've found out that to load a text file from within the JAR you have to use something like: -
    String str = (this.getClass().getResource("/myData.txt")).getFile();
    java.io.File fil = new java.io.File(str);
    java.io.FileReader fr = new java.io.FileReader (fil);
    java.io.BufferedReader bin = new java.io.BufferedReader (fr) ;The sticking point is that my method (ReturnFileAsArray()) is declared as static, because my own FileIO class is just a bunch of static methods to do file I/O stuff. Therefore, I can't use the above method because of the instance variable "this" (I assume).
    Is there any way I can load an included text file as above without having to declare my method as an instance method? I guess I could write a seperate class to do this for my commonfiles package, but I'd rather not if possible.
    Any ideas?

    Don't put a "flag" and code different ways to read files depending on whether it's in a JAR or not. Just use
    the getResource/getResourceAsStream API regardless. Hmmm.....so that will load it from either place depending on the situation? I keep getting a NullPointerException doing that, on this line: -
    String strFileName = (FileIO.class.getResource(fileName)).getFile();...although I've only tried it using the external local filesystem file (in the same directory) as I've not really finished setting up my WebStart stuff yet.
    Here is the method in question...
    public static String[] ReadFileAsArray(String dirName, String fileName, boolean bFromJAR) {
            String[] resultStringArray = null;
            StringBuffer strBuffer = null;
            StringTokenizer strTokenizer = null;
            FileReader fReader = null;
            BufferedReader bReader = null;
            int iElementCount = 0;
            if ((dirName.length() < 1) || (fileName.length() < 1)) {
                // Null parameters found. Failure.
                return null;
            } else {
                // Parameters correct, continue.
                try {
                    // Read the file contents and convert to String array.
                    //if (bFromJAR) {
                        // Open file from within JAR file.
                        String strFileName = (FileIO.class.getResource(fileName)).getFile();
                        File jarFile = new File(strFileName);
                        fReader = new FileReader(jarFile);
                    //} else {
                        // Open from local filesystem.
                    //    fReader = new FileReader(dirName + File.separator + fileName);
                    bReader = new BufferedReader(fReader);
                    strBuffer = new StringBuffer();
                    while (bReader.ready()) {
                        strBuffer.append(bReader.readLine() + "%%");
                    strTokenizer = new StringTokenizer(strBuffer.toString(), "%%");
                    resultStringArray = new String[strTokenizer.countTokens()];
                    while ((strTokenizer.hasMoreTokens()) && (iElementCount < resultStringArray.length)) {
                        resultStringArray[iElementCount++] = strTokenizer.nextToken();
                    bReader.close();
                    return resultStringArray;
                } catch (IOException e) {
                    return null;
        }I'm calling it using: -
    // Load the external file into a String array, one row for each element.
    String[] fileArray = FileIO.ReadFileAsArray(System.getProperty("user.dir"), "datasources.dat", true);Cheers on any info on this.

  • Access wav-files in jar-archives (URL works, File works not)

    Hi there!
    The un-jar-ed application works fine, but I have a problem with accessing files in jar archives.
    URL url = Classname.class.getResource("testdir/test.wav");works fine (and loading images works this way), but as soon as I try to get the file
    File file = new File(url.getFile());I get an null-exception.
    (in my case, I use the jmf package to play the sound-files, and I get the problem when I try to instatiate the MediaLocator
    MediaLocator mediaLocator = new MediaLocator(url);but I think the problem is the same)
    Thanx for help

    works fine Then keep doing it that way. What's the problem? It's true that you can't access something in a jar archive via a File object, so don't do that.

  • Can Time Capsule be used to access video files for editing?  Or do I need a wired hard drive using USB/Firewire/Thunderbolt?

    MORE INFO ABOUT WHAT I AM TRYING TO DO:
    I'm using Final Cut Express 4 and would like to store my video clips on an external hard drive so the internal hard drive in my MacBook Pro 13 doesn't have to work so hard.  I heard from a reliable source that it might be impossible to access the files wirelessley though, meaning that I might need to get a wired external hard drive that uses USB, Firewire or Thunderbolt.
    Any help or suggestions would be greatly appreciated.  Thanks a lot.
    -Rick

    The experts in the iPhoto, Aperture and iMovie support areas all strongly advise against trying to locate a "working" library on a network drive, like the Time Capsule, even if the Mac is hard wired to the Time Capsule. Things would be a lot more dangerous with a wireless connection.
    Apple does as well:
    “Additionally, storing the iPhoto (or other image) library on a network rather than locally on your computer can also lead to poor performance or data loss.”
    http://support.apple.com/kb/TS5168
    You might want to post in the Final Cut Express support area to see if the folks over there feel the same way.
    Final Cut Express HD
    Your best best....if you do not have the space on your Mac's hard drive.....would be to add a USB, FireWire or Thunderbolt drive directly to the Mac to establish a "local" connection. This is much better and more reliable setup that trying to use a network drive, like a Time Capsule.
    Use the Time Capsule for its designed and intended purpose....your backups.....not "working" files. Time Machine on your Mac can back up both your Mac and the attached hard drive to the Time Capsule.

  • Modifying output file to access video file

    I have a project in multiple languages. One of the topics
    accesses several video files (.html). Due to the multiple
    languages, these video files, including the underlying .swf and
    AC_RunActiveContent.js files, are located on the installation CD in
    every language folder causing too many CDs. To reduce the number of
    CDs, we'd like those files on the CD once.
    I talked to RoboHelp support and the only way to accomplish
    this is to modify the path in the output file....redirecting it to
    a parent folder. This worked on image files but doesn't with the
    video files. When I test it, I'm getting runtime errors. The only
    reference listed in the output file is the .html file; there's no
    code referencing the underlying .swf or.js files. Does anyone know
    if there's some other embedded path somewhere that needs to be
    modified to make this work?

    Just open the original project FLA, file->export movie->AVI (uncompressed) and set the dimensions as you mentioned. After you get the movie exported from flash, convert that AVI (already the proper size) to the format you need.
    If you have the Adobe Suite then you have Adobe Media Encoder. It supports MPEG2 (HDV-HD1 is just a specific set of settings for MPEG2). It's pretty darn easy to set up. No reason to pay for more software if you already have it.

  • Issues with embedding large HD video files within keynote

    I posted something over at the FCP forum, but Keynote is starting to get problematic when I import and embed 1 to 2 GB HD video files that have background music.
    1 time Keynote did a hard hang during a project save and lost 20 or so slides although the thumbnails were still showing.
    Trying to save the project is starting to also become a real chore.
    I am exporting 3-5 minute long HD video clips shot at 1080i and then deinterlaced in FCP.
    HDV already reduces image sharpness it is. I want to keep the quality/footage sharpness up as high as possible. The selected video size ends up being about 1065 x 569, but that is a size, not a sharpness, one of the things I always found confusing when referring to it as "resolution".
    So what settings would you suggest when outputting via FCP?
    Any Keynote settings or workflows advised?

    You could try uploading them to a joint dropbox account that they could then download them from....but how fast it is will depend on the internet connection available.

  • Text file within jar file

    Can anybody tell me if it's possible to read and write to a text file stored within the .jar file package? I can maintain a constant file length if that enables me to read and write.
    cheers,
    Steve

    reading a text from, from a jar file..... if the jar is in your classpath you can call
    getClass().getResourceAsStream ( "/myServerConfig.properties" );Note the "/", which stops the file from being interpreted as a class name, see Class.getResourceAsStream()
    writing... nothing as easy as the reading solution above.
    You'd probably have to actually "update" the JAR file contents with a new version of the text file.
    regards,
    Owen

Maybe you are looking for

  • Inernet connection is down, Photoshop won't run

    I have Photoshop installed from my Adobe Cloud account. When I try to run my Photoshop App, it keeps wanting to connect to the Cloud, but I don't need that. I just want to run the app. My MAC is not allowing me to connect to the CLoud right now, inte

  • Q190 HDMI Connection to TV

    This will not work. I can connect to TV using VGA connection. I can connect other devices to TV via HDMI but not the Q190. Any suggestions? Thanks

  • My new Nano has no Fitness "steps" program.

    How can I get the software for the "steps" portion of the Fitness program?

  • Some doubts regarding APD

    Hi Friends, I am working on APD for the first time. While working on it, I came across the following doubts/questions: 1. If we have created a query as the source for APD and transactional ODS as target in Dev. Now, I want to transport this APD in QA

  • Pulp crashing on iPad

    I've been having a problem with Pulp (by Acrylic Software) crashing upon launch on my iPad.  I've sent at least 5 emails to them and no response but I figured it out how to fix. I deleted the app from iPad and then redownloaded immediately from App S