Sorry to start a second thread.

Now I have a big problem. :(

try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("C:/Program Files/Internet Explorer/iexplore.exe D:/Travel Agency/userguide/tutorial.htm");
}
catch (Exception exe) {
}
}

This works perfectly to bring up the tutorial.html using IE. But provided that my IE is at that C:/Program blah blah blah path and my tutorial is at that path. Whenever i change to different locations, i have to edit it. Any idea how to solve this problem?

Recommended Answers

All 4 Replies

Member Avatar for iamthwee

Nope.

You need to specify the exact file location. How else will the computer know where it is?

Imagine D:/Travel Agency/userguide/tutorial.htm could have been placed anywhere. In any drive, and in any directory? How will your computer find it, without having to recursively search the contents of your computer. And that's a helluva lot of drives, and directories to search.

See what I mean?

[edit]btw your avatar is really kewl![/edit]

omg... then it's a killer for me.
cuz my program makes use of both read and write.

reading the tutorials blah blah blah and writing to a textfile after a booking is submitted.

imagine the horrors if I were to burn this into a disc and one part may work (read part) but the other part (write part) is not able to work!

I need a win win situation!!!

just thought of something.

why can't i use ../Travel Agency/userguide/tutorial.htm????

as in, the system will be clever enough to find under whichever directory the main application class is in? E.g: running the app from ../Travel Agency/main.exe

Member Avatar for iamthwee

why can't i use ../Travel Agency/userguide/tutorial.htm????

Well have you tried that? Does it work... I don't know? Just a hunch but I doubt it, the computer still needs to find out the file is. Again it could be anywhere, in any file, and in any directory. And as far as I know there is no magic function that finds the file in question efficently?

The only thing I can think of is to install the files from your cd you intend to release, onto the computer.

So you ask the client, 'where would you like the files to be installed, c:\program files\...'

Then you know for sure that's where it is going to be. After all isn't this how all the other proprietary software companies do it? Or am I misunderstanding what you intend to do?

On the other hand, you do realise that you don't need to specify a path, if the files you intend to read and write from are in the same directory as the program you are running it from?

Better still can you explain exactly what it is you want to do, and how?

hihi, actually it's hard to put into words about what I need to specifically do/achieve. But anyhows, I spent the whole night digging out my notes/pestering my friends and managed to solve the issue by getting the AbsolutePath of the folder. so it works perfectly on my side now. hehehe...

void jMenuHelpTutorial_actionPerformed(ActionEvent e) {
try {
Runtime rt = Runtime.getRuntime();
File userguide = new File("userguide");
Process p = rt.exec("C:/Program Files/Internet Explorer/iexplore.exe " +
userguide.getAbsolutePath() + "/tutorial.htm");
}
catch (Exception exe) {
      System.out.println(exe);
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.