Solved

CLASSPATH?

Posted on 2001-06-11
5
320 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 70 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now