Java Packages

J

João Marques

Hi, I am working with a program named OtsuThresholding_16Bit, but I
can't compile even though I have the code already built. But I need
some packages that don't come already with java and I don't know how
to get them in the right place. The packages are:

import ij.*;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import ij.gui.*;
import ij.plugin.frame.PlugInFrame;

These packages can be found in ImageJ documentation I think.
If anyone knows how I can help me put these packages to work in my
java, I'd appreciate a lot.

Thanks, Joao
 
K

Knute Johnson

João Marques said:
Hi, I am working with a program named OtsuThresholding_16Bit, but I
can't compile even though I have the code already built. But I need
some packages that don't come already with java and I don't know how
to get them in the right place. The packages are:

import ij.*;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import ij.gui.*;
import ij.plugin.frame.PlugInFrame;

These packages can be found in ImageJ documentation I think.
If anyone knows how I can help me put these packages to work in my
java, I'd appreciate a lot.

Thanks, Joao

You need to list the .jar files that those classes come in your
classpath. The easiest method is to put them into the same directory
that you compile your source from and add them to the compile command line.

javac -cp .;some.jar;someother.jar MyClass.java
 
A

Andrew Thompson

..need some packages ... ImageJ ...

I suspect Knute answered a different question
to the one you are asking, but I am not sure.

So, here is my answer.
 
A

Arne Vajhøj

Andrew said:
I suspect Knute answered a different question
to the one you are asking, but I am not sure.

So, here is my answer.

Very likely the original poster needs both: get the jar and
put it in classpath.

Arne
 
J

João Marques

Very likely the original poster needs both: get the jar and
put it in classpath.

Arne

Well I have already downloaded de ImageJ program into my computer.
What I don't know is where those packages can be found. If you can
answer me something else, maybe it would help. When you write "import
java.util.Scanner" for example, and compile the program, the compiler
will know what package you are talking about. But where can you find
it in your computer? Is there a folder where these packages are?
 
A

Arne Vajhøj

João Marques said:
Well I have already downloaded de ImageJ program into my computer.
What I don't know is where those packages can be found. If you can
answer me something else, maybe it would help. When you write "import
java.util.Scanner" for example, and compile the program, the compiler
will know what package you are talking about. But where can you find
it in your computer? Is there a folder where these packages are?

In that case it is Knute's advice you need. You need to
ass the jar file to the classpath.

Like:

javac -classpath foobar.jar Something.java
java -classpath foobar.jar Something

Arne

PS: You don't need to specify anything for the java.util because those
classes are in a jar file that java search by default.
 
M

Mark Space

João Marques said:
Well I have already downloaded de ImageJ program into my computer.
What I don't know is where those packages can be found. If you can

Well, I think you need to help us and tell us what you downloaded and
where you put it. We can't guess.

answer me something else, maybe it would help. When you write "import
java.util.Scanner" for example, and compile the program, the compiler
will know what package you are talking about. But where can you find
it in your computer? Is there a folder where these packages are?

No, it's the other way around. You tell Java where to find the package,
with the classpath. That's why we need to know where you put the thing.

Also, what IDE are you using?


(There is a way to put any library in the default search path, but it's
really evil and can mess up other projects. Better to use the classpath
by far.)
 
J

João Marques

Well, I think you need to help us and tell us what you downloaded and
where you put it.  We can't guess.


No, it's the other way around.  You tell Java where to find the package,
with the classpath.  That's why we need to know where you put the thing..

Also, what IDE are you using?

(There is a way to put any library in the default search path, but it's
really evil and can mess up other projects.  Better to use the classpath
by far.)

I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.
 
J

João Marques

Well, I think you need to help us and tell us what you downloaded and
where you put it.  We can't guess.


No, it's the other way around.  You tell Java where to find the package,
with the classpath.  That's why we need to know where you put the thing..

Also, what IDE are you using?

(There is a way to put any library in the default search path, but it's
really evil and can mess up other projects.  Better to use the classpath
by far.)

I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.
 
J

João Marques

Well, I think you need to help us and tell us what you downloaded and
where you put it.  We can't guess.


No, it's the other way around.  You tell Java where to find the package,
with the classpath.  That's why we need to know where you put the thing..

Also, what IDE are you using?

(There is a way to put any library in the default search path, but it's
really evil and can mess up other projects.  Better to use the classpath
by far.)

I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.
 
J

João Marques

Well, I think you need to help us and tell us what you downloaded and
where you put it.  We can't guess.


No, it's the other way around.  You tell Java where to find the package,
with the classpath.  That's why we need to know where you put the thing..

Also, what IDE are you using?

(There is a way to put any library in the default search path, but it's
really evil and can mess up other projects.  Better to use the classpath
by far.)

I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.
 
L

Lew

João Marques said:
I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.

No need to repeat yourself, the first three times made it through.
 
J

João Marques

Well, I think you need to help us and tell us what you downloaded and
where you put it.  We can't guess.


No, it's the other way around.  You tell Java where to find the package,
with the classpath.  That's why we need to know where you put the thing..

Also, what IDE are you using?

(There is a way to put any library in the default search path, but it's
really evil and can mess up other projects.  Better to use the classpath
by far.)

I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.
 
L

Lew

João Marques said:
I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.

OK, stop.
 
J

João Marques

No need to repeat yourself, the first three times made it through.

Sorry I dont know why it happened. I just sent it once. But everytime
I refreshed another one would appear..i'll read through it then
 
J

João Marques

No need to repeat yourself, the first three times made it through.

Sorry I dont know why it happened. I just sent it once. But everytime
I refreshed another one would appear..i'll read through it then
 
L

Lew

João Marques said:
Sorry I dont know why it happened. I just sent it once. But everytime
I refreshed another one would appear..i'll read through it then

Don't use Google Groups.

If you must, don't use refresh. Obviously you are refreshing the screen from
whence you sent your reply. Just click on one of the links provided by GG to
navigate. Don't use refresh from the screen from which you submitted your reply.
 
V

vk02720

Don't use Google Groups.

If you must, don't use refresh.  Obviously you are refreshing the screen from
whence you sent your reply.  Just click on one of the links provided by GG to
navigate.  Don't use refresh from the screen from which you submitted your reply.

You need to learn
- What a package is and how a class can be qualified with a package
name (analogous to how a file belongs to a folder)
- What classpath is (start with above provided links)
- How to add jars to your project's classpath in your IDE or on the
command line while compiling and executing.
- What jars are already included implicitly in your project (from JRE)
If you are working on Windows, open your jar using WinZip and see if
your packages and classes are there to make sure you have correct jar
files.
 
M

Mark Space

João Marques said:
I have downloaded the packages that I need and I have them in my
Desktop. I tried to set the source path as to include this folder but
it doesn't seem to work. I don't really know how to use classpath. And
I use the JCreator to write my Java programs.

I don't know JCreator. In NetBeans I can right-click on the Library
folder of my project, pick Add Jar... and navigate to the JAR file I
want to include in the project. Maybe you can do the same thing in
JCretaor.

If you're using an Ant build or similar script, we still need a path.
The path to the Desktop varies for different user-names and versions of
Windows and Unix. My Desktop is at:

C:\Users\Brenden\Desktop

Where is your's? And we'll still need the name of your JAR file.

(And yes, please loose the refresh key.)
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top