As per my understanding you want to change the classpath which you have set by command
set classpath=d:java
can be done
in two ways either you can set classpth directly as environment varible by
--> Right click on my computer select advanced options
--> there you will see option as environment variables open that option
--> now you will see multiple variables being set...search for classpath variable if it exist
their edit this variable value by just putting semicolon and write ur full classpath ended by semicolon and save it.
FOR EG:-
variable name:- CLASSAPTH
variable value- .;C:\Oracle\product\10.1.0\Client_2\jdbc\lib\ojdbc14.jar;
Second option is just set your class in command promt as u have set earlier
by opening command prompt
set classpath=C:\Oracle\product\10.1.0\Client_2\jdbc\lib\ojdbc14.jar;
both the method are easy but i would prefer you should go with first one as by doing that you didn't need to set your classpath again and again after you reboot your system or application.
Answer from Mukund Jindal on Stack OverflowJava : How to use a -classpath in the command prompt.
java - Setting Classpath using command prompt in Windows 7 - Stack Overflow
Setting JAVA_HOME path
How to get Intellisense for things in Java Classpath
Videos
As per my understanding you want to change the classpath which you have set by command
set classpath=d:java
can be done
in two ways either you can set classpth directly as environment varible by
--> Right click on my computer select advanced options
--> there you will see option as environment variables open that option
--> now you will see multiple variables being set...search for classpath variable if it exist
their edit this variable value by just putting semicolon and write ur full classpath ended by semicolon and save it.
FOR EG:-
variable name:- CLASSAPTH
variable value- .;C:\Oracle\product\10.1.0\Client_2\jdbc\lib\ojdbc14.jar;
Second option is just set your class in command promt as u have set earlier
by opening command prompt
set classpath=C:\Oracle\product\10.1.0\Client_2\jdbc\lib\ojdbc14.jar;
both the method are easy but i would prefer you should go with first one as by doing that you didn't need to set your classpath again and again after you reboot your system or application.
If u want to do while running your java program ,you can use
java -classpath C:\java\MyClasses utility.myapp.Cool
for more details about class path see oracle documentation about classpath.
So I have two different .java files in two different directories. One contains the main method which calls the other one through its method name. . This is in the directory
E:\JavaWorld\TardyCoder\temp1
Here is my program which contains the main method with the fileName Lemons.java
public class Lemons{
public static void main(String args[]){
Sorra sorraObject = new Sorra();
sorraObject.testName();
}
}My another program is in the directory
E:\JavaWorld\TardyCoder\temp2
Here is my program Sorra.java which doesn't contain the main method.
class Sorra{
public void testName(){
System.out.println("My name is Khan.");
}
}I used -sourcepath to create two .class files like this:
E:\JavaWorld\TardyCoder\temp1>javac -sourcepath E:\JavaWorld\TardyCoder\temp2 Lemons.java
Everything worked perfectly and i got two .class files in their respective directories.
Now I tried to use the -classpath to get the output like this:
E:\JavaWorld\TardyCoder\temp1>java -classpath .; E:\JavaWorld\TardyCoder\temp2 Lemons
But I'm getting an error :(
Error: Could not find or load main class E:\JavaWorld\TardyCoder\temp2
Please explain the right way to use -classpath in command prompt.
Edit: Got the answer. There should be no space after .;
I'm not a Java programmer, so I don't know the correct value for CLASSPATH. But, you seem to. You can add it to ~/.bashrc like so:
CLASSPATH=/path/to/1:/path/to/2:/etc
The change will take effect globally the next time you log in. However, it will take effect immediately in new shells.
Additionally, if you want to set it for just one particular command, do this:
CLASSPATH=/something command-here arg1 arg2
A third way would be to create a wrapper script, which would be appropriate if you needed to set multiple variables or if you needed to determine appropriate values programmatically:
#!/bin/bash
export CLASSPATH=/something
export ANOTHER_ENV_Variable=foo
exec your_fancy_program "$@"
that's what happened with me.. i left empty spaces while typing.. it fixed when i removed spaces.
1) if you want to set classpath permanently then 1) find out where java is installed.. you may use " whereis java " openjdk-7/6 is in /usr/lib/jvm/.....
2) we need to set up CLASSPATH in /etc/environment
sudo gedit /etc/environment
3) add the following likes .. ( DONT LEAVE ANY SPACES WHILE TYPING)(customize according to your java version and installation) (this home path is for open jdk 7)
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386/bin"
export JAVA_HOME
CLASSPATH=".:/usr/lib/jvm/java-7-openjdk-i386/lib:/home/laptop/Desktop/a2"
export CLASSPATH
separate directory by ":"