• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jave Program Execuction issue  RSS feed

 
Shivv Krishna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Am new to java, i am getting an error while executing programs from command line and from Text Pad editor.
Same program working fine from Eclipse Tool.

I have installed java (Jdk1.0.8_20, Jre1.0.8_20).

While am running program from command line i am getting below error:

C:\>javac Test.java
javac: file not found: Test.java
Usage: javac <options> <source files>
use -help for a list of possible options

Same Test.Java running fine when i go to specific folder where i have saved Test.Java file:
C:\Automation\Practice Java>javac Test.Java

This file compiled and run the program successfully.

Through Eclipse IDE:
Am able to run the same program without any issues.

Through Test Pad Editor:
I am getting an error while compiling this program:

javac: invalid flag: C:\Automation\Practice Java\Test.Java
Usage: javac <options> <source files>
use -help for a list of possible options

Tool completed with exit code 2


i have set environment variable :
Variable Name: Path
Veriable Value: C:\Program Files\Java\jdk1.8.0_20\bin
Under User Variables for administrator.

I have logged into PC with administrator account.

Please guide me how to fix this issue
 
Dave Tolls
Ranch Foreman
Posts: 3065
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is your issue?

The first bit is how javac works. You need to give the correct path to the file you want to compile, or be in the directory with that file, as you saw in the second part.

Eclipse "knows" this, which is why it works.
I have no idea about the TextPad issue.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

That is what normally happens. You navigate to the folder where the file is and compile it there. You cannot find the file in the C drive because it isn't called Test there. It is called "Automation\Practice Java\Test.java".

I don't think you have done anything wrong. But if you are very new, avoid Eclipse. Use a plain ismple text editor. There is so much to learn, the complexities of the IDE may overwhelm your thoughts.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that PATH a user variable or a system variable? If it is a user variable, it is all right, but you will have to change it next time there is an updated version of the JDK. If you have deleted part of the system PATH, however, you may find all sorts of other things fail to work.
 
Shivv Krishna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all of you. we have some investigation and came to know that we saved a java file with .Java extenstion. Where we need to save with .java.

Finally got the issue resolved.

-S
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done sorting it out and telling us the answer
Although Windows® might not notice the difference between Test.java and Test.Java, the javac tool being written in Java will notice the difference. I hardly ever use Windows® so I can double‑click a file name and feed it back to the terminal with the middle mouse button. Saves no end of trouble with spelling errors!
 
Shivv Krishna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed extension of java file with Java to java and complited it once again. Looks like Textpad editor is having issue while am saving my program with .Java extension.

This is only the change i did after posting this thread and noticed it's started working.

-S
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!