The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Run it differently

Posted by Shankar on October 02, 2001 at 3:04 AM

> I have a very silly question. Let's say I have two classes. One named TextReader.java and the other named LeapYear.java. Let's also say that LeapYear.java creates a new instance of TextReader named keyboard. Both of these files reside in the same folder. There are no defined packages. When I run my code in JBuilder, it runs perfectly, no errors. I can compile TextReader from the command prompt (with javac) with no problems. When I try to compile LeapYear from the command prompt with javac, I get the following error:

> C:\test>javac LeapYear.java
> LeapYear.java:7: cannot resolve symbol
> symbol : class TextReader
> location: class LeapYear
> TextReader keyboard = new TextReader();
> ^
> LeapYear.java:7: cannot resolve symbol
> symbol : class TextReader
> location: class LeapYear
> TextReader keyboard = new TextReader();

> If both of these files are located in the same folder, why can't javac find TextReader? This seems like such a simple thing, I must be missing something obvious.


Hello,
This problem is because of JBuilder. As the previous reply from MFG says, when u write a program in JBuilder,it automatically creates a pakage and stores it in that package. U can also see in ur program(s) when openend in JBUilder that the package name will be written.
So, u have 3 opions.
1. Write the code in pure java(out of JBuilder, in notepad / any editor) and run them. This will defintely run.
2. Compile and run the applns in JBuilder. Dont compile in JBuilder and run in prompt.
3.Compile in JBuilder and u can run it from Command prompt by going out of the package path and running:
Ex: If the program(s) are in c:\temp\bin\LeapYear.java & c:\temp\bin\TextReader.java, then compile in c: as

c:\javac temp\bin\TextReader.java
c:\javac temp\bin\LeapYear.java
It will succeed
Also run as
c:\java temp.bin.TextReader
or
c:\java temp.bin.LeapYear

-Shankar



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us