Hi All,
I'm trying to run a sample program from this link:
http://java.about.com/od/tutorials/ss/SetClasspath.htm
it worked fine.. now the problem is... what if i do not want to use the set classpath command, instead, i just want to set the classpath in my system environment variable so that everytime i run the program, i'll just type javac file then java file. I tried to set this in the environment variable :
variable name: classpath
variable values: c:\javatest
but its not working... can anyone help me with this?
Thanks,
Pupoy
11 1753
Can you show us what you originally set using the -classpath flag? For the
environment version everything is similar: as a flag:
-classpath=foo
and as an environment variable:
set classpath=foo
kind regards,
Jos
Hi Jos,
Thanks for the reply... i tried to type this in the command line :
STEP1 : set PATH = c:\program files\Java\jdk1.6.0_03\bin
STEP2 : javac C:\javatest\BarkingDogs.java
(Then specify where to find the class)
STEP3 : java -cp c:\javatest BarkingDogs
after completing these steps... i had a successful ran of the snippet...
Now, correct me if i'm wrong...is it correct that i can run the program by just typing :
* (for compiling)
javac BarkingDogs.java
* (for running program)
java BarkingDogs
meaning running the program by just doing steps 2 and 3(without cp word in step 3) since class path is already in environment variable.
Back to the original question... i just added under system environment variables :
variable name: classpath
variable value: ?
i'm using windows xp
Thanks,
Pupoy
Your reasoning is all sound and solid but you have to pay special attention to
those path names with spaces in them. You need to use double quotes around
them otherwise MS Windows starts to be creative which you don't want.
kind regards,
Jos
i dont get the spaces... u mean in the classpath values?
by the way, can you please give me a working class path for windows... just to accomplish the 2 steps i mentioned in my previous post:
javac BarkingDogs.java
java BarkingDogs
and... do i really always have to tell the windows where the java compiler is(Set path command) ? can't i just include it in the class path? separated by ;
Thanks,
Pupoy
There are a few separate issues that have not much to do with each other: The PATH variable
The PATH variable is a semi colon separated list of directories. The OS searches
those directories for executable files for which no explicit complete path was
given. java.exe and javac.exe are examples of executable files. The CLASSPATH variable
The CLASSPATH variable is a semi colon separated list of directories and .jar
files. The JVM searches them for classes.
So you have to set your PATH variable to a suitable value if you just want to be
able to type 'java' or 'javac'. You have to set your CLASSPATH to the directories
where your .class files are stored and to the complete names of your .jar files.
If you want to be able to type 'javac MyClass.java' you have to change your
current working directory to where your MyClass.java file is stored.
btw. the space character I mentioned is present in the 'Program Files' directory
name. You have to take care of it by using double quotes. Check your manuals.
kind regards,
Jos
Hi,
I know what executable files are... LOLZ.
btw, its just that i'm not really familiar on how to set the windows environment variable configuration. that's all. ROTFL...
thanks Jos, ^^ ;
Kind regards,
Pupoy
Hi,
I know what executable files are... LOLZ.
btw, its just that i'm not really familiar on how to set the windows environment variable configuration. that's all. ROTFL...
thanks Jos, ^^ ;
Kind regards,
Pupoy
Check your Windows manuals for that issue, it has nothing to do with Java.
kind regards,
Jos
I tried to create a new variable in the environment variables of windows...
variable : CLASSPATH
value : c:\javatest
still, i can't make it run in root directory :
c:\>javac BarkingDogs.java
c:\>java BarkingDogs
once classpath is defined in environment variable.... the system should already know the class location right? using java and javac keywords should trigger the variable classpath and tell the computer to get the value of the classpath variable...why is it still not working?
Thanks again,
Pupoy
I tried to create a new variable in the environment variables of windows...
variable : CLASSPATH
value : c:\javatest
still, i can't make it run in root directory :
c:\>javac BarkingDogs.java
c:\>java BarkingDogs
once classpath is defined in environment variable.... the system should already know the class location right? using java and javac keywords should trigger the variable classpath and tell the computer to get the value of the classpath variable...why is it still not working?
Thanks again,
Pupoy
You can't compile a file BarkingDogs.java when your current working directory
is not the directory where that file is stored.
kind regards,
Jos
hmm.... I tried to add classpath variable in the user variables (the one at the top)
, it worked for running the class file. but when i try to compile .java files... it can't locate the directory of classpath.
c:\>javac BarkingDogs.java = (Doesn't work)
(lets say the directory contains class files)
c:\>java BarkingDogs = (successful !)
here's my classpath variable :
variable : classpath
variable value : .;c:\javatest
It seems that the system can now see the classpath variable when using java command. but if i'll try to use javac command.... hmm... not working?! that's weired ! (FYI : i already added in system variable the path of java compiler
i.e. c:\program files\Java\jdk1.6.0_03\bin
Thanks again,
Pupoy
just received your reply jos. thanks. so it's not possible to use javac command in any directory even if you've set the classpath variable. only java command to execute the file will work. now i understand. thanks man.
Thread closed.
Thanks,
Pupoy
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Herman |
last post by:
Hi everyone, I recently installed the Sun J2SE SDK on my machine, and
I am having trouble running the java.exe interpreter for my Java
compiled code. I remember that I had to set my environment...
|
by: David Cook |
last post by:
Windows (XP and NT) allows one to specify environmental variable
(such as PATH and CLASSPATH) at both the SYSTEM-wide level
as well as at the per-USER level.
And the behavior has always been...
|
by: Paul |
last post by:
hi , i have started with "beginning JSP web development" and got stuck
on extending classes. I'm getting the following error message:
TechnicalBook.java:3: cannot resolve symbol
symbol : class...
|
by: Dave Keays |
last post by:
I am setting-up an experimental web service using Apache Axis but I'm having problems. AXIS can't find a library that I've verified exists on my computer and that CLASSPATH points to it.
I'm using...
|
by: Digital Puer |
last post by:
I am writing Java user defined functions running in DB2 8 on Windows XP.
For some reason the Windows system environment CLASSPATH is not being
passed to my Java UDF (i.e. when I println the...
|
by: jeremiah johnson |
last post by:
Okay this is going to sound really dumb. Skeet, you can poke fun of me
in your own special way if you see fit.
Is there a way to reproduce the CLASSPATH functionality of Java within
C#? Would...
|
by: dlarsson |
last post by:
Okay folks, I thought I was doing something very, very simple,
but I cannot seem to get this to work at all.
Can anyone identify what I am doing wrong here-?
_________________________________
...
|
by: KevinRobinson |
last post by:
Hi,
Can anyone please tell me how to add or change a Java classpath in SUSE
Linux 9.3.
I have set up a Tomcat server but my Java Classes will not run although they
do on a windows box.
...
|
by: giantfatiguana |
last post by:
hey all im a beginner java user and am getting an error relating to the classpath i assume.
I have a file JM550b.java which is trying to access the class QTCycle when compiling. QTCycle.java...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |