1

I have tried to compile a java program, shorten.java from mp4parser site. But my jar file is unable to resolve the required import shown below. This program needs to import library from iso mp4parser as mentioned below. In short I need jar file for shorten.java file to resolve these import.

import com.coremedia.iso.IsoFile;
import com.coremedia.iso.boxes.TimeToSampleBox;
import com.googlecode.mp4parser.authoring.Movie;
import com.googlecode.mp4parser.authoring.Track;
import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder;
import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator;
import com.googlecode.mp4parser.authoring.tracks.CroppedTrack;

I have downloaded the source code from the mp4parser site to create the jar file for these library.

In below image java->com->coremedia->iso and java->com->coremedia->iso->boxes having required java program

and java->com->googlecode->mp4parser->authoring etc. having other needed java program for these import

I have created the jar by following command-

cd  java           // moved in java folder

jar cfv mp4parser.jar   *

now add these jar to my shorten.java program. But I am getting error that import is not resolved.

****Do anybody can tell me where I am doing mistake ???****

Here is the directory where java codes for these imports are available.

directory structure for included java code

Thor
  • 6,607
  • 13
  • 62
  • 96
Vishal
  • 673
  • 3
  • 12
  • 24
  • jars are imported into your project/module as a separate step in your IDE. They are not be picked up automagically based on which directory you add them to. Which IDE are you using? – Peter Lawrey Oct 02 '12 at 13:18
  • Hi Peter, I am using Eclipse. I have created the jar by command prompt and then attach jar from build path. I am sure I am attaching correctly because I have attached jar files before with other program – Vishal Oct 02 '12 at 13:24
  • If you are attaching jars you built in a manner which worked correctly before then its likely you have built the jars incorrectly. When you examine the `jar` does it have `.class` files or `.java` files? – Peter Lawrey Oct 02 '12 at 13:33
  • how to check does my jar have .class or .java file??? – Vishal Oct 02 '12 at 13:40
  • You can unpack it or list it with `jar -tv` , but I thought eclipse has a viewer for jars. – Peter Lawrey Oct 02 '12 at 13:42
  • Sorry for late reply, Got some other work. I have seen my jar, it is having .java files only. Do I need require .class files for my purpose. – Vishal Oct 04 '12 at 01:45
  • It has to contain the compiled .class files. You can add the .java files but these will be ignored. – Peter Lawrey Oct 04 '12 at 07:12

1 Answers1

0

I suggest you to this:

  • Create a quickstart java project with maven;
  • Add the dependencies that you want;
  • Put the java class in src/main/java
  • mvn clean install

If it don't work, try some IDE, like eclipse. Open the project and try to fix the imports... It's always possible that some lib has changed, and maybe they change the name of the package.

caarlos0
  • 20,020
  • 27
  • 85
  • 160
  • Hi caarlos, can you pls tell me little bit more how to do this with eclipse?? I have checked that name is not changed. – Vishal Oct 02 '12 at 13:22
  • you know how to use eclipse? and maven? explain a little more your problem and I'll try to help you. – caarlos0 Oct 02 '12 at 13:25
  • My problem is that I have the source code for the required libraries in mentioned import. Then I have created the jar from this source code But its giving compilation error that import is not resolved – Vishal Oct 02 '12 at 13:29
  • as I said, maybe the libraries changed... maybe the import used in your file was deprecated, and now you will have to use another one.. is just a guess.. but, generally, that's the problem.. – caarlos0 Oct 02 '12 at 13:33
  • source code for these imported libraries are from http://code.google.com/p/mp4parser/source/browse/#svn%2Ftrunk%2Fisoparser – Vishal Oct 02 '12 at 13:34
  • Actually both the code and source code from where I am creating jar file, both are latest. So I dont think its deprecated – Vishal Oct 02 '12 at 13:38
  • do you have maven installed? if yes, go to the directory of the project and run `mvn clean install eclipse:eclipse`. It should download all the required libraries automatically and configure you eclipse to use it. The jar will be generated in your local repo (usually `YOUR_USER_HOME/.m2/repository` – caarlos0 Oct 02 '12 at 13:44