aspose file tools*
The moose likes Beginning Java and the fly likes cannot find [filename].java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot find [filename].java" Watch "cannot find [filename].java" New topic
Author

cannot find [filename].java

Rekha Anand
Ranch Hand

Joined: Feb 23, 2008
Posts: 36
Hello.

I have JDK1.3 installed on my system. Obviously, the JVM is in c:\jdk1.3\bin folder. Any .java file created in the bin folder runs fine. But if i save my .java source code in some other folder say c:\jdk1.3\bin\prog\abc.java and try to compile it, I get an error "File cannot be found". Please help me.
Dhaval Shah
Ranch Hand

Joined: Jun 10, 2005
Posts: 56
Please execute this command on the command prompt -
> set classpath=%classpath%;c:\jdk1.3\bin\prog

As a result when you run the program the compile would be able to find the file that needs to be executed


Thanks and Regards,<br />Dhaval Shah<br />SCJP 1.4<br />SCWCD 1.4
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

First, do not put your own .java or .class files in the JDK's bin directory. This is for Java's "inner workings," and mixing your own files in there is bound to complicate things.

If there is no CLASSPATH specified, Java's default (since version 1.2) is to look in the current directory. So it sounds like you have a system CLASSPATH set (so you're not getting the default behavior) and the set CLASSPATH does not include a dot (.) to indicate the current directory.

The best approach is to avoid a system CLASSPATH entirely. But if you must set one, be sure it includes a dot.

See Java 1.3 Installation Instructions - Classpath for more details.
[ February 26, 2008: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Rekha Anand
Ranch Hand

Joined: Feb 23, 2008
Posts: 36
Thank you very much!!

I tried >set classpath=%classpath%;c:\jdk1.3\bin\rekha progs
but still javac cannot find my file !!


Regards
Rekha

P.S. rekha progs is the folder containing my java source code files.
[ February 27, 2008: Message edited by: Rekha Anand ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

When compiling, first change your current directory to the directory that contains the source file...

C:\>cd jdk1.3\bin\rekha progs

Then compile from that directory...

C:\jdk1.3\bin\rekha progs>javac abc.java

After it's compiled (when you get a new prompt with no error messages), then try running with...

C:\jdk1.3\bin\rekha progs>java abc

If this fails with a "no class definition found" error, then try specifying the current directory (.) as a classpath...

C:\jdk1.3\bin\rekha progs>java -cp . abc

Let us know how this works.
[ February 27, 2008: Message edited by: marc weber ]
Rekha Anand
Ranch Hand

Joined: Feb 23, 2008
Posts: 36
Thanks a lot for your help!!

I tried the following:
C:\>jdk1.3\bin\rekha progs\javac abc.java

But I still got an error. This time it says - 'javac' is not recognised as an internal or external command.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
Carefully re-read marc's post. In particular note the difference between


and


It seems you missed the step



Ping & DNS - my free Android networking tools app
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Rekha Anand:
...it says - 'javac' is not recognised as an internal or external command...

That suggests that you haven't updated your PATH variable. See step 4 of Sun's Java installation instructions.

After that, please note Ulf's post above.
Rekha Anand
Ranch Hand

Joined: Feb 23, 2008
Posts: 36
In my previous post, I placed the > symbol at the wrong place. Sorry about that. I very well understand that I had to CD first. What I meant to write was
c:\jdk1.3\bin\rekha progs>javac abc.java

This command gave me the error 'javac' cannot be recognized as an internal or external command.

I would like to mention that I have set the path and the classpath to
path=%path%;c:\jdk1.3\bin\rekha progs

and classpath=%classpath%;c:\jdk1.3\bin\rekha progs

but still i am not able to compile the source code from rekha progs folder.

I am sorry that the problem is stretching..

Regards
Rekha
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Rekha Anand:
...I would like to mention that I have set the path and the classpath to
path=%path%;c:\jdk1.3\bin\rekha progs

and classpath=%classpath%;c:\jdk1.3\bin\rekha progs...

The PATH should point to...

C:\jdk1.3\bin

...because that's where the executable tools are (like javac and java). It should not point to the "rekha progs" directory. See Update the PATH variable in the installation instructions.

A system CLASSPATH should not be needed at all, because Java's default is to look in the current directory. If you do need a system CLASSPATH (and again, you probably do not need this), then make sure it includes a dot (.) so that class files can be found in the current directory. See Check the CLASSPATH variable in the installation instructions.
Rekha Anand
Ranch Hand

Joined: Feb 23, 2008
Posts: 36
Finally... I got it. I want to thank all forum members who helped me on this.

Regards
Rekha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot find [filename].java