• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How do you include libraries (JMF specifically)?

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I installed JMF (Java Media Framework). It is necessary for a test file that I ran. It worked perfectly. I was just wondering how do I include JMF libraries in my program. I use the command line and Notepad++, so IEDs are a no go. Do I just put in my code:

and then in my JAR file include the jmf.jar file?
I've never used or made a library in an application, so sorry if I'm totally off.
Thanks,
cc11rocks aka John Price
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't import files (you import packages) and then add the corresponding jar files to your classpath at runtime (the classpath can contain multiple jar files).
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm so frustrated, I'm about to shoot Java.
Where all the JAR files are: "E:\MediaTest"
Where the two class files I need are "E:"
I am running it off of my flash drive.
Here is the error I receive when I try to run it...

How do I make this work?
Here is the DIR for E:

DIR for E:\MediaTest:

What the heck?
Here is MediaTest.java and MediaPanel.java
MediaPanel.java:

MediaTest.java:

cc11rocks aka John Price
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.lang.NoClassDefFoundError: E:\MediaTest


That's the key part: you're specifying a class called "E:\MediaTest" which doesn't exist (because the class is called "MediaTest"). Class names and file names are not the same thing, and are not interchangeable. The "E:\" part needs to go into the classpath. So instead of

java -cp E:\MediaTest\*.jar;E:\MediaTest\*.properties;E:\MediaTest\*.properties.orig E:\MediaTest

you need something like

java -cp E:\MediaTest\*.jar;E:\MediaTest\*.properties;E:\MediaTest\*.properties.orig;E:\ MediaTest
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works now, thank you. Now I want to convert the class files into an executable jar file. Would I just do the same thing?
Something like this? :

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You wouldn't specify a classpath (it's not needed). But you may want to include the properties files in the jar file (depending on what those are, and how they get used).
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But how does the JAR just know to look for a library?
Thanks,
cc11rocks aka John Price
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would "jar" need access to the libraries? It's a tool to bundle files (specifically, class files) together.

Or are you saying that you want to bundle ALL classes -including JMF- into a single jar file? That would be more involved, and not really necessary. Not commonly done, either.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you give me a working example? It keeps saying "No media player found" on another computer (that does not have JMF installed). The example should include a JAR file (with 1-2 classes) and a library (preferabley in the form of a JAR file). I am having SOOO much trouble with this.
John Price aka cc11rocks

EDIT: Just found something that may fix the "problem".

http://download.oracle.com/javase/tutorial/deployment/jar/downman.html

The solution goes in the manifest file, specifying the class path.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, that was the solution. I just had to add:

to the manifest file.
The weird thing is that mp3 files are not working...
If you know what is wrong, please share.
Thanks,
cc11rocks aka John Price
 
Not so fast naughty spawn! I want you to know about
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic