Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java imported package does not exist

I am trying to use pdfbox to write a simple pdf file but the problem is that I am getting error :

cannot find symbol class PDDocument

I have downloaded the jar files into the same folder the program exists. How to fix this compilation error?

package org.apache.pdfbox.pdmodel.PDDocument;

import java.io.*;
import org.apache.pdfbox.pdmodel.PDDocument;

public class pdf
{
public static void main(String args[])
{
}
}
like image 330
user1952529 Avatar asked May 12 '13 05:05

user1952529


People also ask

How do you fix Java package does not exist?

Add a Java transformation in a mapping. Add the jars in the Java Transformation under Java Code > Settings > Add Classpath to use classes from c:\sample\Myjar. jar jar file. Add the import statement that corresponds to the class file in the jar.

Why we do not import Java Lang package?

No, java. lang package is a default package in Java therefore, there is no need to import it explicitly. i.e. without importing you can access the classes of this package.

What is the meaning of package system does not exist in Java?

somethingElse the compiler assumes you are doing a packageName. classname . In this case you were intending to access out of the System class, but you could very well be trying to access a package called system that is not present (in the classpath for instance). So it is a guess from a compiler.


1 Answers

Putting the jar in the same folder or package does not add it to the class path. You need to mention the path of the jar in your class path while running your java program. Here is the syntax for that:

To compile:

javac -classpath .;yourjar.jar src/your/package/*.java

To run

java -classpath .;yourjar.jar src/your/package/yourprogrammeclassname
like image 65
Juned Ahsan Avatar answered Sep 28 '22 01:09

Juned Ahsan