For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2005 > run any location?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author run any location?
Pete

2005-02-25, 4:00 am

do you have to be in the directory of the .class file you're trying to
run? or can i be somewhere else, as so:

file location:
C:\javaprograms>helloWorld.class

my location:
C:\

can i do this or something like it?
java javaprograms\helloWorld

it has allowed me to compile that way as so:
javac javaprograms\helloWorld.java
while in the aforementioned user location, i.e. C:\ with the file in
the preceding file location, i.e. C:\javaprograms>helloWorld.class

but i have not been able to execute a program that way..... so can i
run a .class file without being in the current directory of that
file???

if not, i don't understand why the j2sdk-1_4_2_07 would allow
compilation, but not execution in that manner.....

Thanks!

Pete

Wiseguy

2005-02-25, 4:00 am

"Pete" <pete@ima-web.com> scribbled on the stall wall:
> do you have to be in the directory of the .class file you're trying to
> run? or can i be somewhere else, as so:
>
> file location:
> C:\javaprograms>helloWorld.class
>
> my location:
> C:\
>
> can i do this or something like it?
> java javaprograms\helloWorld


try

java -cp c:\javaprograms helloWorld

As long as the location of your class file is in the classpath it should
find it.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com