Java JAR files

T

Teber

Hi,

I've a Java library file which is called Klavye.jar. I write a
program which uses this library. This library is in
com.boragungoren.java package. the program looks like this:

import com.boragungoren.java.Klavye;

public class Main {

public static void main(String[] args) {

int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();

}

}

the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib

when compile it says

Main.java:2: package com.boragungoren.java does not exist
import com.boragungoren.java.Klavye;
^
what shall i do
what is wrong with this
Thanks Teber Ozceyhan
 
R

rossum

Hi,

I've a Java library file which is called Klavye.jar. I write a
program which uses this library. This library is in
com.boragungoren.java package. the program looks like this:

import com.boragungoren.java.Klavye;

public class Main {

public static void main(String[] args) {

int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();

}

}

the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib

when compile it says

Main.java:2: package com.boragungoren.java does not exist
import com.boragungoren.java.Klavye;
^
what shall i do
what is wrong with this
Thanks Teber Ozceyhan
In Java your package name must match the location of the files for
that package. Your Klavye.jar needs to be in
###/com/boragungoren/java/, which is where the compiler will be
looking for it. The error message is telling you that it cannot find
anything at ###/com/boragungoren/java. "###" will vary depending on
where in your directory tree you keep your java programs.

HTH

rossum
 
T

Teber

I've a Java library file which is called Klavye.jar. I write a
program which uses this library. This library is in
com.boragungoren.java package. the program looks like this:
import com.boragungoren.java.Klavye;
public class Main {
public static void main(String[] args) {
int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();


the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib
when compile it says
Main.java:2: package com.boragungoren.java does not exist
import com.boragungoren.java.Klavye;
^
what shall i do
what is wrong with this
Thanks Teber Ozceyhan

In Java your package name must match the location of the files for
that package. Your Klavye.jar needs to be in
###/com/boragungoren/java/, which is where the compiler will be
looking for it. The error message is telling you that it cannot find
anything at ###/com/boragungoren/java. "###" will vary depending on
where in your directory tree you keep your java programs.

HTH

rossum

Main.java is in c:\xxx
i'we created the directories within this directory so that c:\xxx\com
\boragungoren\java\ the jar file is in this directory but the compiler
says the same thing.

i've created this directory structure C:\Program Files\Java
\jdk1.6.0_03\jre\lib but the result is the same...

Thanks

Teber
 
J

John

Hi,
I've a Java library file which is called Klavye.jar. I write a
program which uses this library. This library is in
com.boragungoren.java package. the program looks like this:
import com.boragungoren.java.Klavye;
public class Main {
public static void main(String[] args) {
int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();
}
}
the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib

I'm not sure of the correct syntax, but I think your CLASSPATH is
wrong.
It should be something like:
C:\Program Files\Java\jdk1.6.0_03\jre\lib\Klavye.jar

for your program to find the jar file.
Sorry I can't be more specific, but I seem to have a lot of problems
with
defining the classpath on my own projects.
Main.java is in c:\xxx
i'we created the directories within this directory so that c:\xxx\com
\boragungoren\java\ the jar file is in this directory but the compiler
says the same thing.

i've created this directory structure C:\Program Files\Java
\jdk1.6.0_03\jre\lib but the result is the same...

Thanks

Teber

John
 
L

Lew

Having "java" inside package names is a bad idea. Isn't the whole program
written in Java?

It's also illegal to have 'java' or 'javax' be top-level package names, but
that doesn't apply here.

Do you have a class called 'Klavye' inside the JAR, in that package?

What package is 'Main' in? It needs to be in a package.
public class Main {

public static void main(String[] args) {

int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();

}

}

the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib

That classpath will not pull in the JAR - you need to explicitly include JARs
in the classpath, or use the wildcard form.

The CLASSPATH envar is not the best way to set a classpath. Use the
-classpath or -cp options to the command instead.

You did not include the JAR in your classpath.
In Java your package name must match the location of the files for
that package. Your Klavye.jar needs to be in
###/com/boragungoren/java/, which is where the compiler will be

Not even close to correct. The class file needs to be in the correct package
directory *inside the JAR*, not the JAR inside the directory.
looking for it. The error message is telling you that it cannot find
anything at ###/com/boragungoren/java. "###" will vary depending on
where in your directory tree you keep your java programs.

Don't put application JARs in the Java installation directories.
$JDK_HOME/jre/lib is for the JRE, not for application code.

Put the JAR in the class path, not in the package directory.

Read
<http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html>
 
K

Knute Johnson

Teber said:
Hi,
I've a Java library file which is called Klavye.jar. I write a
program which uses this library. This library is in
com.boragungoren.java package. the program looks like this:
import com.boragungoren.java.Klavye;
public class Main {
public static void main(String[] args) {
int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();
}
}
the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib
when compile it says
Main.java:2: package com.boragungoren.java does not exist
import com.boragungoren.java.Klavye;
^
what shall i do
what is wrong with this
Thanks Teber Ozceyhan
In Java your package name must match the location of the files for
that package. Your Klavye.jar needs to be in
###/com/boragungoren/java/, which is where the compiler will be
looking for it. The error message is telling you that it cannot find
anything at ###/com/boragungoren/java. "###" will vary depending on
where in your directory tree you keep your java programs.

HTH

rossum

Main.java is in c:\xxx
i'we created the directories within this directory so that c:\xxx\com
\boragungoren\java\ the jar file is in this directory but the compiler
says the same thing.

i've created this directory structure C:\Program Files\Java
\jdk1.6.0_03\jre\lib but the result is the same...

Thanks

Teber

I wrote a command line program that will list out all the class files in
your classpath. You might use it to debug your problem. Please post
back if it was useful to you.

http://rabbitbrush.frazmtn.com/Classpath.java

Also there is an article discussing the Java classpath at

http://rabbitbrush.frazmtn.com/classpath.html
 
R

rossum

Not even close to correct. The class file needs to be in the correct package
directory *inside the JAR*, not the JAR inside the directory.
Thanks for the correction, my bad.
Don't put application JARs in the Java installation directories.
$JDK_HOME/jre/lib is for the JRE, not for application code.
That was what I meant to say: "where in your directory tree you keep
your java programs" would have been better expressed as "where in your
directory tree you keep your own java programs that you have written".

rossum
 
L

Lew

Rooamin said:
You need to set your -classpath. The compiler will look in the classpath for
the folder structure com\boragungoren\java.
Here is a link to help you:
http://java.sun.com/j2se/1.3/docs/tooldocs/findingclasses.html

Really? You're providing links to an obsolete version of Java? Even 1.4 has
reached its End-of-Life period and is scheduled to retire this year. Version
1.3 is way past its life.
<http://java.sun.com/j2se/1.4.2/>

They've changed some of the details of how the classpath specifies JARs since
then.

<http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html>
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>
 
R

Rooamin

Lew said:
Really? You're providing links to an obsolete version of Java? Even 1.4
has reached its End-of-Life period and is scheduled to retire this year.
Version 1.3 is way past its life.
<http://java.sun.com/j2se/1.4.2/>

They've changed some of the details of how the classpath specifies JARs
since then.

<http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html>
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>
Thanks for the updated links.
 
T

Teber

Teber said:
Hi,
I've a Java library file which is called Klavye.jar. I write a
program which uses this library. This library is in
com.boragungoren.java package. the program looks like this:
import com.boragungoren.java.Klavye;
public class Main {
public static void main(String[] args) {
int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();
}
}
the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib
when compile it says
Main.java:2: package com.boragungoren.java does not exist
import com.boragungoren.java.Klavye;
^
what shall i do
what is wrong with this
Thanks Teber Ozceyhan
In Java your package name must match the location of the files for
that package. Your Klavye.jar needs to be in
###/com/boragungoren/java/, which is where the compiler will be
looking for it. The error message is telling you that it cannot find
anything at ###/com/boragungoren/java. "###" will vary depending on
where in your directory tree you keep your java programs.
HTH
rossum
Main.java is in c:\xxx
i'we created the directories within this directory so that c:\xxx\com
\boragungoren\java\ the jar file is in this directory but the compiler
says the same thing.
i've created this directory structure C:\Program Files\Java
\jdk1.6.0_03\jre\lib but the result is the same...

Teber

I wrote a command line program that will list out all the class files in
your classpath. You might use it to debug your problem. Please post
back if it was useful to you.

http://rabbitbrush.frazmtn.com/Classpath.java

i couldn't execute this program there is no problem when compiling but
couldnt run...
Also there is an article discussing the Java classpath at

http://rabbitbrush.frazmtn.com/classpath.html

this documentation was realy helpfull

very thanks...
 
T

Teber

Having "java" inside package names is a bad idea. Isn't the whole program
written in Java?

It's also illegal to have 'java' or 'javax' be top-level package names, but
that doesn't apply here.

Do you have a class called 'Klavye' inside the JAR, in that package?

What package is 'Main' in? It needs to be in a package.


public class Main {
public static void main(String[] args) {
int k;
long l;
System.out.println("Two number please:");
k=Klavye.intOku();
l=Klavye.longOku();
}
}
the Klavye.jar is in C:\Program Files\Java\jdk1.6.0_03\jre\lib
CLASSPATH is C:\Program Files\Java\jdk1.6.0_03\jre\lib

That classpath will not pull in the JAR - you need to explicitly include JARs
in the classpath, or use the wildcard form.

The CLASSPATH envar is not the best way to set a classpath. Use the
-classpath or -cp options to the command instead.

You did not include the JAR in your classpath.
In Java your package name must match the location of the files for
that package. Your Klavye.jar needs to be in
###/com/boragungoren/java/, which is where the compiler will be

Not even close to correct. The class file needs to be in the correct package
directory *inside the JAR*, not the JAR inside the directory.
looking for it. The error message is telling you that it cannot find
anything at ###/com/boragungoren/java. "###" will vary depending on
where in your directory tree you keep your java programs.

Don't put application JARs in the Java installation directories.
$JDK_HOME/jre/lib is for the JRE, not for application code.

Put the JAR in the class path, not in the package directory.

Read
<http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html>

Thanks for help this was too helpfull first i will reorganize the JAR
its nor mine but it's not inth form \com\xxxx\yyyy i thing that was
the problem...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top