Java & Command Prompt Project

Michael.Chute

Baseband Member
Messages
26
Location
United States
I'm doing a class project and I'm trying to copy the following to a text document but for the life of me can not figure out why it's not saving the line response to a text document and instead it's only creating a text document in the same name but with no information.

"C:\Program Files\Java\jdk1.7.0_25\bin\java" > "JVM.txt"

I've done other lines similar to this such as:
cd./ > "Copy File.txt"

Any idea as to why I can't copy it?
 
Try using the cat command to display contents of file to screen then redirect to file.
 
The command line:
cat myfilename will show the contents of the file on the screen.
cat myfilename > savefilename will save to file savefilename instead of displaying.

Hope this helps.
 
The above work in you using linux. if using Dos then
type filename > save filename.

What is ur OS?
 
I think the OP is trying to save a stream/directory/etc. within a text file. Not trying to rename a current file... And for windows Dos it would be "filename > newfilename" anyway.

I could be wrong though..
 
I think the OP is trying to save a stream/directory/etc. within a text file. Not trying to rename a current file... And for windows Dos it would be "filename > newfilename" anyway.

I could be wrong though..

I'm using Windows 8, sorry I did not provide this. I was just trying to save the command line output from my last command to save to a file, something like you mentioned above. My full code is:

cd\
mkdir "Lab II"
dir
cd "Lab II"
dir
dir/?
cd. > "Copy File.txt"
dir
copy "Copy File.txt" "Copy File 2.txt"
dir
notepad.exe
set
set CLASSPATH=.;c:\jdkl1.7.0_25\bin
set > "Set.txt"
notepad "Set.txt"
mkdir "My Folder"
dir
mkdir "HelloWorldApp"
copy "C:\Users\Michael\SkyDrive\Documents\Michael Chute\Salem State University\Software Design & Programming I\Lab I\HelloWorldApp\src\HelloWorldApp\HelloWorldApp.java" "C:\Lab II\HelloWorldApp"
cd "HelloWorldApp"
dir
"C:\Program Files\Java\jdk1.7.0_25\bin\javac"
"C:\Program Files\Java\jdk1.7.0_25\bin\javac" *.java
dir
dir > "Folder Listing.txt"
dir
notepad.exe "Folder Listing.txt"
cd..
dir
"C:\Program Files\Java\jdk1.7.0_25\bin\java"
"C:\Program Files\Java\jdk1.7.0_25\bin\java" > "JVM.txt"
"C:\Program Files\Java\jdk1.7.0_25\bin\java" "helloworldapp"."HelloWorldApp"
 
That line is renaming it to "JVM.txt"

Are you trying to copy the contents of the "C:\Program Files\Java\jdk1.7.0_25\bin\java" directory into a text file?

If "C:\Program Files\Java\jdk1.7.0_25\bin\java" is in fact a directory, then go to it within cmd and type:
dir > "JVM.txt"

That will create a text file with all files/directories listed inside of it. Is that what you mean?
 
Back
Top Bottom