Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,184,296 members, 7,923,360 topics. Date: Saturday, 17 August 2024 at 01:30 AM

Critical Question For Programmer Gurus - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Critical Question For Programmer Gurus (2987 Views)

A Question For Yii2 Users / I Am Looking For Programmer That Are Way Smarter Than Me / Interview Questions For Programmer/analyst (2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: Critical Question For Programmer Gurus by Otuabaroku: 12:18pm On Jun 10, 2011
omo_to_dun:

Wrong! In windows, there are two types of environment variables namely: user variables and system variables. Setting a variable, say PATH, as a user variable will restrict it to the account of the person setting it while setting the variable as system variable(you have to have administrative privileges to do this) will make it available for all the accounts in the system. You set the CLASSPATH when you want the location of your class packages to be known to the JVM. For example, if I have some classes, say Driver.class, Mechanic.class, Person.class, and Test.class in a package edu.caltech which is in turn located in the folder C:\omo_to_dun\nairaland\2011,

I can then add C:\omo_to_dun\nairaland\2011\ to my CLASSPATH so that I can import them like so:

import edu.caltech.*;

If I do not add C:\omo_to_dun\nairaland\2011\ [/b]to my [b]CLASSPATH, then the above import will fail, unless I am currently in the directory C:\omo_to_dun\nairaland\2011.

So, stop laughing in Swahili and pick up a good Java Book!

^^^ I laugh again in Swahili. What I said before is what you are repeating all over again. Windows has two environmental variables, user and system variables. CLASSPATH is located at the System variables while the PATH is located at the user variables. And I asked the guy to copy the java bin directory to his CLASSPATH that is located at the system variable( by doing so, all users of the system would have access to it). Please, tell me how is this different to what I said before or what you just stated. @omo_to_dun na you know grin
Re: Critical Question For Programmer Gurus by Nobody: 12:32pm On Jun 10, 2011
Otuabaroku:

And I asked the guy to copy the java bin directory to  his CLASSPATH that is located at the system variable( by doing so, all users of the system would have access to it). Please, tell me how is this different to what I said before or what you just stated. @omo_to_dun  na you know grin
Because setting CLASSPATH only affects the classes you want to import---it does not add the directory where java, javac, appletviewer and all the other programs you need to compile and run java programs are located, which is what the OP wanted. If he had added C:\Sun\SDK\java\bin to CLASSPATH, but not to PATH, typing java at the command line wouldn't work. I understand what you are saying, but if he wants to set his Java Development Environment for all users he has to set PATH as a system variable. PATH is not exclusive to user variables, you can also create a new variable in system called PATH and add your directories to it.

Otuabaroku:

Windows has two environmental variables, user and system variables. CLASSPATH is located at the System  variables while the PATH is located at the user variables.
Your understanding is severely limited! Not every account on Windows has a user variable called PATH. My PATH variable exists as a system variable(Windows 7). Of course, I can create a PATH user variable if I wanted to, in which case the setting would affect only my account. Who says CLASSPATH is located at the system variables? You really need to read more! CLASSPATH system variable is created either by you or some other user with administrative privileges(it does not come with Windows) and you can make it a user or system variable, depending on how you want it to affect other accounts. And really, unless you are developing a large scale application, no one sets the CLASSPATH. The OP is a newbie, he does not need to set CLASSPATH until he starts modularizing his classes and placing them in packages. Like I said, CLASSPATH is not exclusive to system variables, you can have PATH as both user and system variables. You can also have CLASSPATH as both user and system variable. Matter of fact, you can have any legal string as both user and system variables. For example, if I have CLASSPATH in system variables, then this CLASSPATH will be set for everyone on the system, as you correctly pointed out. However, if I want the CLASSPATH to affect only me, then I'll create a variable called CLASSPATH as user variable to that effect. Try it: set only your CLASSPATH an see if you can compile anything. (Of course, you'd have to unset the PATH variable).

Official tutorial on CLASSPATH and PATH variables
http://download.oracle.com/javase/tutorial/essential/environment/paths.html

Once again CLASSPATH sets directories for class packages, while PATH sets directories for location of development binaries.
Re: Critical Question For Programmer Gurus by Luka316(m): 1:54pm On Jun 10, 2011
@all infact iam learning from your argument, but pls is enough, let it not lead to something else[when two elephant fight is the grass(me) that suffers]

@omo_to_dun pls how can i get the[b] examples of code found in [/b] "Java how to program 6e" i try downloading it from their (deitel) website but i could'nt pls if u can i would e greatful.
thx
Re: Critical Question For Programmer Gurus by Otuabaroku: 2:15pm On Jun 10, 2011
Luka316:

@all infact iam learning from your argument, but pls is enough, let it not lead to something else[when two elephant fight is the grass(me) that suffers]

@omo_to_dun pls how can i get the[b] examples of code found in [/b] "Java how to program 6e" i try downloading it from their (deitel) website but i could'nt pls if u can i would e greatful.
thx
^^^ We are not fighting but to get the points straight.

omo_to_dun:

Because setting CLASSPATH only affects the classes you want to import---it does not add the directory where java, javac, appletviewer and all the other programs you need to compile and run java programs are located, which is what the OP wanted. If he had added C:\Sun\SDK\java\bin to CLASSPATH, but not to PATH, typing java at the command line wouldn't work. I understand what you are saying, but if he wants to set his Java Development Environment for all users he has to set PATH as a system variable. PATH is not exclusive to user variables, you can also create a new variable in system called PATH and add your directories to it.
Your understanding is severely limited! Not every account on Windows has a user variable called PATH. My PATH variable exists as a system variable(Windows 7). Of course, I can create a PATH user variable if I wanted to, in which case the setting would affect only my account. Who says CLASSPATH is located at the system variables? You really need to read more! CLASSPATH system variable is created either by you or some other user with administrative privileges(it does not come with Windows) and you can make it a user or system variable, depending on how you want it to affect other accounts. And really, unless you are developing a large scale application, no one sets the CLASSPATH. The OP is a newbie, he does not need to set CLASSPATH until he starts modularizing his classes and placing them in packages. Like I said, CLASSPATH is not exclusive to system variables, you can have PATH as both user and system variables. You can also have CLASSPATH as both user and system variable. Matter of fact, you can have any legal string as both user and system variables. For example, if I have CLASSPATH in system variables, then this CLASSPATH will be set for everyone on the system, as you correctly pointed out. However, if I want the CLASSPATH to affect only me, then I'll create a variable called CLASSPATH as user variable to that effect. Try it: set only your CLASSPATH an see if you can compile anything. (Of course, you'd have to unset the PATH variable).

Official tutorial on CLASSPATH and PATH variables
http://download.oracle.com/javase/tutorial/essential/environment/paths.html

Once again CLASSPATH sets directories for class packages, while PATH sets directories for location of development binaries.

^^^ The fact is that all you have been saying all over again is the same thing I stated but you failed to see from my perspective;anyway good for you. Once again, na you know grin.
Re: Critical Question For Programmer Gurus by Nobody: 7:10pm On Jun 10, 2011
^
You keep saying na you know. Can you please explain to us why a programmer will need to set the CLASSPATH? Prove me wrong! Set only the CLASSPATH and see if your program will compile. All you have to do is post a picture of your terminal with values of PATH and CLASSPATH. We are not saying the same thing!
Re: Critical Question For Programmer Gurus by Luka316(m): 8:52pm On Jun 10, 2011
@omo_to_dun and Otuabaroku pls enough of that clarification i have tried to watch and listen (shocked) but is bcoming boring and uneducative, pls if there is a way for both of to help me, just like omo_to_dun deed i would be glad.

@omo_to_dun i have finaly downloaded the code examples of java how to program 6e; pls if there is help for my java how to program pls do help me, iam studying it seriusly.

thank you all
Re: Critical Question For Programmer Gurus by Roseburn: 10:06pm On Jun 14, 2011
TRY THIS:
Open your command line. Type the following:
1.cd drive:/directory (Where drive cud be C or D and directory is the path to the folder you installed your jdk and press enter).
2.set CLASSPATH= (press enter).

Now, you can use javac to compile and run your program using java command.

You may do this whenever you face such problem.
Please try to get an IDE say Eclipse.
Im a newbie Java programmer, anyway.
Re: Critical Question For Programmer Gurus by Roseburn: 10:12pm On Jun 14, 2011
My user name is not roseburn pple. Alexander will be the right one. NL admin pls correct the error.
Re: Critical Question For Programmer Gurus by Fayimora(m): 12:33am On Jun 15, 2011
What error?
Re: Critical Question For Programmer Gurus by Luka316(m): 3:35pm On Jun 15, 2011
@roseburn(Alexdra) thx for the infor

(1) (2) (Reply)

Get A Custom Website For As Low As 5k (Check Thread For My Portfolio) / Best OS For Programmers / Where Can I Learn Programming In Illorin?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 48
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.