jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes accessing java files within folders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "accessing java files within folders" Watch "accessing java files within folders" New topic

accessing java files within folders

Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
I have this test2.java file which is accessed using
C:/>cd my/my1/
C:/my/my1>java test2.java 89 89
I'm passing two arguments to the file test2.java
now this is when i'm doing it mannually....!!!
Now the actual thing that i have to do is .. that i have a main file called write_to_file.java...and this file takes parameter from jsp and thses parameters are passed to test2.java
So.. when the test2.file is in the same location as of write_to_file.java ..... in my code i'm executing the cmd line like this
Runtime rt = Runtime.getRuntime();
String cmd = "java test2";
cmd = cmd + " "+ data ; // parameters 89 89
Process proc = rt.exec(cmd);
System.out.println("do something");
... now i want to know what do i have to write so that i can access the test2.java if it's under two folders
I have tried writing
String cmd = "my/my1>java test2";
but this doesnot work...infact the it doesnot take it as a command line even .... it just displays the entire string.....
Plz tell me how would i execute the test2.java file from write_to_file.java if test2.java is under other folders...
pls help..
Thank u
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
How about

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
Thank u soooooo much Lasse .... ur idea worked..!!
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
hi all....
Wanted to know whether this is possible or not..
I have two files....
one html file and one jave file .... is it possible to pass values from the html file to the java file.....???
Example :
In my HTML form i have a text box user name .... can i pass the value from this text box on Submit to my java program.... which is residing in a folder supposing C:\>cd myfolder\java file....

In the above post the cmd 'java -classpath C:\my\my1 java file' was to be written inorder to access the java file in another folder. ... how will i be able to access the java file which is with in a folder from a html form....and how will the values be passed???
plz do let me know..!
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
plz do tell... is there a way to do the above..?
I agree. Here's the link: http://aspose.com/file-tools
subject: accessing java files within folders