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.
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.
Related
I am trying to sort my classes into packages but i can't import them.
My files are in the following folders:
- .java files are in C:\Java\Code\src\my\app\Timer
- .class files are in C:\Java\Code\compiled\my\app\Timer
In my class (timer) i've added package my.app;
Also, I have setted the CLASSPATH to look in both src and compiled folders.
Then, I have another folder where I put my "bigger" projects in:
- C:\Java\Projects\myProject
The problem is that when I try to import the class Timer into MyProject using import my.app.*; all I get is:
Error: package my.app does not exist
Culd you please give me a hand?
PS. My IDE is Dr.Java
I have found the problem.
It appears that Dr.Java ignores complitely the CLASSPATH variable. It is necessary to set in preferences where are the .class files.
I am trying to read and write modifications to an XML file. After much research I selected the JDOM approach for this activity. I'm not doing big files and I just need something quick and simple. I downloaded the JDOM project files from jdom.org/downloads/docs.html. I also downloaded some exmple files that show the read write code using JDOM. Piece of cake Right?
Wrong. I have screwed around for several weeks trying to get my Java JDOM project to work. Using Eclipse on Windows 7 PC. I can not get the import statements to actually import the required JDOM items.
I have my project files in S:\Java\procXML folder. The source files are in the S:\Java\procXML\src\procXML folder.
The JDOM files in my S:\Java\JDOM folder. The JDOM java source files are in the S:\Java\JDOM\core\src\java\org\jdom2 folder.
I have the CLASSPATH set to S:\Java\JDOM\core\src\java.
I get an error message from Eclipse saying the org.jdom2 imports cannot be resolved.
The import section of the procXMLfile is as follows:
package procXML;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
public class procXMLfile {
public static void main(String[] args) {
// TODO Auto-generated method stub
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File("c:\\file.xml");
This stuff should be simple. The reason I'm using java is because I need to write some programs for MAC and Android and Java can be compiled for all of those platforms. I'm about ready to get rid of java and go with so other language, so I'm hoping someone can tell me what is wrong.
You are adding a source folder in your CLASSPATH.
Java classpath doesn't know how to interpret your source project.
You could compile your code through javac or via Eclipse to get a JAR file.
But if you just want to use JDOM in your project (which seems to be the case here), the simplest way is to add already packaged jar to your CLASSPATH:
Download the latest binaries from JDOM
Unzip them in a folder, for instance S:\Java\procXML\lib
Add in your classpath the jar inside the lib folders: S:\Java\procXML\lib\jdom-2.0.6.jar,S:\Java\procXML\lib\lib\jaxen-1.1.6.jar, S:\Java\procXML\lib\lib\xercesImpl.jar, S:\Java\procXML\lib\lib\xml-apis.jar, S:\Java\procXML\lib\lib\xalan\serializer-2.7.2.jar, S:\Java\procXML\lib\lib\xalan\xalan-2.7.2.jar
In my linux, I have my java files that I coped from my windows eclipse project, and now I want to compile it in linux.
The folder structure is
PlutoMake.java
java-json.jar
Filter\ColorFilter.java
Filter\Darken.java
Filter\NoFilter.java
Filter\VividLight.java
The PlutoMake file has these imports and some others too like for json
import Filter.ColorFilter;
import Filter.Darken;
import Filter.NoFilter;
import Filter.VividLight;
But when I try to compile plutomake, it says
PlutoMake.java:12: package Filter does not exist
import Filter.ColorFilter;
I already use this to compile it:
javac -cp "java-json.jar" PlutoMake.java
and similarly for other ones too.
Does anyone know how to import it?
Thanks
You are getting package Filter does not exist error because the Filter.* classes are not present in the class path.
First compile the java files in side the folder Filter then compile the PlutoMake.java using javac -cp "java-json.jar;." PlutoMake.java
I'll advice to use some build tool like Maven or Gradle or Ant
If i understand the question correctly. In eclipse just go to fil > Import > Existing Projects into Workspace
Select your project and import all your files. Then hit finish.
Are they in the right subdirectories?
If you put /usr/share/'classpath', files defined with package Filter should be in /usr/share/Classes/Filter/
try setting java -classpath
I want to user from file upload in Java OFBiz but when i do the following error occur:
import java.io.FileOutPutStream;
import org.apache.commons.fileUpload;
and other io, and apache packages bellow error occur:
Can not find symbol import java.io.FileOutPutStream Symbol: class FileOutPutStream
and another error
package org.apache.commons.fileupload does not exist.
I use eclipse , and the following is structure of path that code stored:
hot-deploy->my_project->src->file.java for Java files
hot-deploy->my_project->widget->myScreens->fileUploadScreens.xml
'hot-deploy->my_project->widget->myForms->fileUploadForms.xml'
But their is no lib folder inside WEB-INF
Your import statements are wrong, they should be
import java.io.FileOutputStream;
import org.apache.commons.fileupload.*;
I recommend to set up a new OFBiz module using the ant target
./ant create-component
and answer the following questions. This will install a skeleton module in hot-deply and will be able to access everything OFBiz delivers OOTB.
You should also check if the OFBiz .project file for Eclipse is read correctly. You should see a lot of source (src) folders and libraries in the project properties/build path of your project. if not, your .project file is not recognized.
I developed two .jar for my application (LOG.jar and STRING.jar).
I use these jar, with import in .java :
import LOG.CLog
import STRING.CString
It's OK. But .jar is increasing in my project, so I would like to create only one .jar which includes all .jar developed.
So I tried this by creating the only one .jar (named TOOLS.jar) :
jar.exe cvmf MANIFEST.MF TOOLS.jar TOOLS\LOG.jar TOOLS\STRING.jar
But, if I put only TOOLS.jar file in my application compilation (Java build path in Eclipse), I get error when I want to import :
import TOOLS.LOG.CLog
This import cannot be resolved.
And In Eclipse "referenced libraries", I see package PXTOOLS which includes both STRING.jar and LOG.jar, but I don't see STRING and LOG package !
How can I fix it ?
I use these jar, with import in .java
:
import LOG.CLog import STRING.CString
You import classes by qualifying them with package names; not directly from JAR files. I hope your package is called LOG and class is CLog here (though it's a bad naming convention to have uppercase package names)
Secondly, merging JAR files into one isn't recommended. It's best to keep them separate. If at all you did want to merge, you must ensure that you extract all the class files first and then merge.
You cannot include jars in a jar file. If you want to deliver just one jar, check out tools like One-Jar. They can package a working jar for you.
I use these jar, with import in .java :
import LOG.CLog import STRING.CString
You import classes by qualifying them with package names; not directly from JAR files. I hope your package is called LOG and class is CLog here (though it's a bad naming convention to have uppercase package names)
Secondly, merging JAR files into one isn't recommended. It's best to keep them separate. If at all you did want to merge, you must ensure that you extract all the class files first and then merge.
Yes, you can do so. Have a look here - Build Java entire project jar using JDeveloper