Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

Get command line directory from java

Thread view: 
mhust6@gmail.com - 19 Aug 2005 19:01 GMT
Here is my situation:

I have a .bat file that can be called from several different
directories.  This .bat file calls a JAVA class, which in turn creates
a document.  This document is always created in the directory that the
.bat file changes to.  Is there a way in the JAVA class to retrieve the
directoy that the .bat file was called from (the directory that the
command line was at), so that the document is created in that one
instead?

Currently to do this, I have to send in the arguement with an absolute
path, which I don't want to have to do.

Thanks for the help.

Matt
Jeff Schwab - 20 Aug 2005 04:58 GMT
> Here is my situation:
>
[quoted text clipped - 8 lines]
> Currently to do this, I have to send in the arguement with an absolute
> path, which I don't want to have to do.

That path is available in the batch file as %CD%.  You can pass that as
an argument from the batch file to your Java program.
hust6 - 22 Aug 2005 15:38 GMT
This is a possibility.  By chance, is there anyway that I could
retrieve the directory without passing the directory to the Java
program.  I realize this may be far-fetched, but could it be possible?
Jeff Schwab - 23 Aug 2005 04:14 GMT
> This is a possibility.  By chance, is there anyway that I could
> retrieve the directory without passing the directory to the Java
> program.  I realize this may be far-fetched, but could it be possible?

I don't know of any way to get the command line unless the shell is
willing to give it up.  Some shell interpreters are also servers that
can be queried via sockets for this sort of information; tclsh comes to
mind.  I don't think CMD.EXE is anything like that sophisticated, though.
Yakov Fain - 29 Aug 2005 17:21 GMT
Matt,

Have you tried System.getProperty("user.dir")?

Yakov Fain

> Here is my situation:
>
[quoted text clipped - 12 lines]
>
> Matt


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.