Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CLASSPATH?

Posted on 2001-06-11
5
Medium Priority
?
356 Views
Last Modified: 2013-11-23
Hi.
I am new in Java.My question is how can I edit CLASSPATH
environment variable. On my computer I have JBuilder4 together with JDK1.3 installed. Now when I create classes in my own packages and then try to import from other projects it says that it cannot open directory with the name of the package, since since directory where my package is, not included into CLASSPATH, so I need to edit CLASSPATH every time I create my own packages, but I don't know how to do it with JBuilder installed.
Thanks.
0
Comment
Question by:alex108
5 Comments
 
LVL 3

Expert Comment

by:superschlonz
ID: 6178794
Go to the Project Menu and press Project Properties.
In tabsheet Paths you have a tabsheet Requred Libraries
The click Add and a windo opens with title
'Select one or more libraries'
There you can click 'new' and enter the path or jar file where
your classes are.
0
 

Expert Comment

by:Sparrow1
ID: 6178971
I think the easiest way to add a classpath is to add a "global" path. In this way, your classpath variable will point to both the jar files anywhere specified AND the currently active directory (ie: where the user-created files are).

To do this, I just edit my autoexec.bat and add/change the line:
Set classpath = c:\thatOtherJarFile\FILENAME.jar;

to

Set classpath= c:\ThatOtherJarFiles\FILENAME.jar;.;

by adding "." as the location of the classpaths you are adding the "current directory" no matter where that happens to be.

Note: The ";" is a seperator between paths.
0
 

Author Comment

by:alex108
ID: 6180194
When I tried to do through Project Properties after I clicked Add and selected the path it writes "No new source, documantation or classpath were found" and it doesn't add.
0
 
LVL 3

Accepted Solution

by:
dnoelpp earned 210 total points
ID: 6182019
Did you use packages in your source? (Do you have a package ....; line at the top of the java files?) Then maybe you have a problem messing up with the path and the package path and the classpath...

EXAMPLE:

1. You hava a class Alpha in the empty package (without package statement in the file Alpha.java) and put it in the directory C:\myclasses.

2. You have a classpath 'C:\myclasses'

==> Java will find the class Alpha.

Let's continue!

3. You hava a class Beta in the package 'mypackage' (first statement in the file Beta.java is: package mypackage;) and put it in the same directory.

==> Java won't find the class Beta.

Why?

Because packages make subdirectories! Put it in C:\myclasses\mypackage, and voila! Java is successful again.

If the package is: mycompany.mypackage, then you have to store the class in C:\myclasses\mycompany\mypackage.
0
 

Author Comment

by:alex108
ID: 6183115
Thank you, I succeeded.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question