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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
these tools give you an invisible CLASSPATH.
;JOOP!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
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?
That was for:
>> is there anyway that i don have to edit the classpath?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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!
;JOOP!
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.
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!
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.
Impossible.
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
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).
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.
Add it to the classpath variable, not the path. If it is not there, then make a new one.
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.
Cool, it works now. thank you.
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
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
You can use that refactor to move / rename your package, class-name, method name and what not.