Link to home
Start Free TrialLog in
Avatar of jtcy
jtcy

asked on

import problem

Very easy question. Can someone tell me how to import a class which resides in a folder outside current folder?

i have a Abc.java in abc folder, and i want to import cde.java which resides in cde folder, and cde folder and abc folder both resides in def folder.

ASKER CERTIFIED SOLUTION
Avatar of sciuriware
sciuriware

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using Eclipse IDE (might be possible with all the IDE's), there you have refactoring choice.

You can use that refactor to move / rename your package, class-name, method name and what not.
Avatar of Mayank S
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jtcy
jtcy

ASKER

is there anyway that i don have to edit the classpath?
By the way, by using ECLIPSE or JBuilder the importing is made easier as
these tools give you an invisible CLASSPATH.

;JOOP!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OOPS!  Misunderstood the question!

if abc and cde folders are within def folder.

Then you have to give the classpath till def folder.

No other way!
>> Posted in your other question.

That was for:

>> is there anyway that i don have to edit the classpath?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jtcy

ASKER

hm..ok thanks guys
By the way, why a C :-(

A C grade is given if the answer is not good, not if the question is easy.
Did we solve your problems? Can you work now?

;JOOP!
Avatar of jtcy

ASKER

hm....donno...i don think the lecturer would want us to..change classpath or smth.

we are told to write two classes, one in seperate directory. each labelled with its own folder name as package. just as what i had described above, a folder includes a.java, b folder includes b.java, both folders resides in x folder. i wan to have b import a.java, but find no way to do that. i don think the lecturer would want us to change the classpath, if so, they would have to change classpath for every student's to mark.
I think the lecturer expects every student to find out that he/she must set CLASSPATH for himself
as you probably must do for the rest of your life.

Then again: full pathname!


;JOOP!
Class-path is the correct way to do it. Don't *think* what the lecturer might want or might not want. Just do whatever he wants in the way it is to be done.
>> i don think the lecturer would want us to change the classpath

Impossible.
Avatar of jtcy

ASKER

ok, how to change the classpath?
i went to environment variable there, adding the full folder path to the path variable, but...not working
Have you visited your other question:

https://www.experts-exchange.com/questions/20940990/import-problem.html

?? You can also set it from the command prompt. When you add the folder path, add only till the parent folder of abc and cde (i.e., only till the dce folder).
>> adding the full folder path to the path variable

Add it to the classpath variable, not the path. If it is not there, then make a new one.
Avatar of jtcy

ASKER

>>?? You can also set it from the command prompt. When you add the folder path, add only till the parent folder of abc and >>cde (i.e., only till the dce folder).


Cool, it works now. thank you.
Avatar of jtcy

ASKER

can I ask how to set the classpath back to original. i mean....if i wan to get rid of that from classpath
First of all - this question is closed. So we'd better discuss it in the other question you opened at:

https://www.experts-exchange.com/questions/20940990/import-problem.html

- you did not need to open two questions for asking the same thing, that too with the same subject! Everytime I receive a mail-notification, I don't know whether it is for this one or that one. Sometimes I miss the other one if there are two.

If you want to delete something from the classpath, you can edit it always. set classpath=.... // whatever