This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes executing java program whose class file is in diff path Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "executing java program whose class file is in diff path" Watch "executing java program whose class file is in diff path" New topic
Author

executing java program whose class file is in diff path

jeevanandam palani
Greenhorn

Joined: Dec 16, 2009
Posts: 5
hi
the Sample.class is in Desktop/myclass folder.
i want to execute it from Desktop

what should i do
help me......


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Check out URLClassLoader. Don't get the name fool you, you can also represent files as URLs. For instance:


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
jeevanandam palani
Greenhorn

Joined: Dec 16, 2009
Posts: 5
in command prompt i want to execute like
java Sample

but classnotfounderror is shown
help me to execute in command prompt..

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

The Java documentation includes a description on How Classes are Found. The easiest thing would be to include the folder where Sample can be found on the command line, like so:


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
jeevanandam palani
Greenhorn

Joined: Dec 16, 2009
Posts: 5
i think using classpath option while executing will work,but i dont know how to set the classpath while executing

something like
java -classpath <path> classname

but i don't know how to specify the path,
explanation with example would be even better.
can anyone help me please....
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

jeevanandam palani wrote:but i don't know how to specify the path,
explanation with example would be even better.
can anyone help me please....


Did you even look at what I posted?
jeevanandam palani
Greenhorn

Joined: Dec 16, 2009
Posts: 5
Hi Joe Ess,
Your idea is working fine.Thanks for your reply.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

It seems I misunderstood the problem; I thought that you wanted to execute your Java program from another Java program. For your problem the class path is exactly what you need.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: executing java program whose class file is in diff path
 
Similar Threads
Playing sounds
permutation program
permutation & combination
Attaching Pictures
quick question about exercise 1-1