A Conversation for The H2G2 Programmers' Corner
DOS commands in Java
Din'Amarth Started conversation Jun 2, 2004
I'm pretty new to Java, and I'm looking for something that is equivilent to "shell" in basic. Any thoughts?
DOS commands in Java
Terran Posted Jun 3, 2004
You mean Shell as in when you type shell it immediately gives a visual list of directory's and where you can have a list of program's which you can go to immediately?
I maybe thinking of the wrong thing, but when I programmed in QuickBASIC, thats what Shell did when I was working in a solely DOS based environment.
I don't think anything like that exists for Java. Not to the best of my knowledge anyway.
I think I'd need to know more about what you're trying to do.
DOS commands in Java
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Jun 3, 2004
If it saves a little time, I could point out that Java runs in a "Virtual Machine", and only has access to data in its own "Sandbox". It's been specifically written so it can *never* access files or data outside the confines of the language itself. The upshot of this is, as far as I know, that it's impossible to pass filesystem-level commands from Java to the machine that is hosting it. This is a design feature of the language, not a bug - if you need to be able to read external files you need to be programming in a different language.
DOS commands in Java
Ion the Naysayer Posted Jun 5, 2004
It's been specifically written so it can *never* access files or data outside the confines of the language itself.
This depends on what application is being developed - for browser-displayed applets this is (generally) true; for full-blown applications you can read and write files but you have to do it Java's way.
What DOS commands were you looking to execute? move, copy, dir, etc? I may be able to point you to the documentation for an equivalent Java class.
DOS commands in Java
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Jun 5, 2004
DOS commands in Java
Ion the Naysayer Posted Jun 6, 2004
I couldn't see an application programming language being very useful if it didn't have the capacity to read or write files.
DOS commands in Java
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Jun 6, 2004
"An applet cannot ordinarily read or write files on the host that is executing it.
The JDK Applet Viewer actually permits some user-specified exceptions to this rule, but Netscape Navigator 2.0, for example, does not. Applets in any applet viewer can read files specified with full URLs, instead of by a filename. A workaround for not being to write files is to have the applet forward data to an application on the host the applet came from. This application can write the data files on its own host. See Working with a Server-Side Application for more examples."
The above is taken from Sun's security notes...
http://java.sun.com/docs/books/tutorial/applet/practical/security.html
DOS commands in Java
Ion the Naysayer Posted Jun 7, 2004
No argument here but that only applies to applets. If the software will be an application there are fewer hoops to jump through for file access.
DOS commands in Java
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Jun 7, 2004
Key: Complain about this post
DOS commands in Java
- 1: Din'Amarth (Jun 2, 2004)
- 2: Terran (Jun 3, 2004)
- 3: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Jun 3, 2004)
- 4: Ion the Naysayer (Jun 5, 2004)
- 5: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Jun 5, 2004)
- 6: Ion the Naysayer (Jun 6, 2004)
- 7: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Jun 6, 2004)
- 8: Ion the Naysayer (Jun 7, 2004)
- 9: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Jun 7, 2004)
More Conversations for The H2G2 Programmers' Corner
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."