aspose file tools*
The moose likes Beginning Java and the fly likes Help with Java compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with Java compilation error" Watch "Help with Java compilation error" New topic
Author

Help with Java compilation error

sailaja cherukuri
Greenhorn

Joined: May 02, 2013
Posts: 9
what i did is i wrote first 2 progs with out main method it will compile ...so these 2 programs can be used my other classes..
so i wrote one more prog as PremierSearch... to call these 2 methods..
the first 2 progs it compiled ...
so my prob is for the 3rd prog i am getting 2 errors.. so how to overcome these errors...

public class InternetSearchEngine {
static void search() {
System.out.println("Found 20 results on Web");
}
}
...........
public class DirectorySearchEngine {
static void search() {
System.out.println("Found 10 results on Novel Directory");
}
}

...............

public class PremierSearch {
public static void main(String args[]) {
search();
InternetSearchEngine.search();
DirectorySearchEngine.search();
System.out.println(" Search Completed ");
}
static void search() {
System.out.println("Found 5 results in Local");
}
}

PremierSearch.java:6: error: cannot find symbol
InternetSearchEngine.search();

symbol: variable DirectorySearchEngine
location: class PremierSearch
2 errors
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Please use code tags and properly indented code like I mentioned in a reply to your previous post. Can't understand why you should be getting these errors. Nothing looks odd to me. When are you getting these errors? When trying to compile the 3rd source file is it? In what order are you compiling?


~ Mansukh
sailaja cherukuri
Greenhorn

Joined: May 02, 2013
Posts: 9
i am writing the code in notepad ........... i am not using eclipss etc.... i am sryy frm the next prgm i will use eclipss ... thankuuu
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

I never told you that you should use eclipse. If you are a beginner, please use notepad++ or some other text editor but not an IDE. Why are you saying sorry? What I was asking you to do is simply to paste code in tags as follows:



Now please explain when are you getting the above errors.
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

Hi sailaja,

Are all three classes you mentioned in the same package ???


http://plainoldjavaobject.blogspot.in
sailaja cherukuri
Greenhorn

Joined: May 02, 2013
Posts: 9
package example;

class calculator
{
public static void main(String args[])
{
System.out.println("this is a package example");
}
}
sailaja cherukuri
Greenhorn

Joined: May 02, 2013
Posts: 9
the above prob i need to compile as javac example\calculator.java

i am trying to compile a class that uses package........ but i am getting an error

file not found: example\calculator.java.......

Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
sailaja cherukuri wrote:the above prob i need to compile as javac example\calculator.java

i am trying to compile a class that uses package........ but i am getting an error

file not found: example\calculator.java.......


Does the directory you are running javac from contain a directory called example and does that directory contain a file called calculator.java ?
sailaja cherukuri
Greenhorn

Joined: May 02, 2013
Posts: 9
yes .... the directory is example... in that directory calculator.java is a filee........ i have to execute class in that directoryy...
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

But from where / which directory are you executing this command?
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 223

sailaja cherukuri wrote:the above prob i need to compile as javac example\calculator.java

i am trying to compile a class that uses package........ but i am getting an error

file not found: example\calculator.java.......



Compiling the java code from this command requires you get into the directory which is just above the example.

And can you show the directory structure of the 3 classes that you wrote above?
As i see all the three classes should be in same package as the modifiers of the methods you are using in the PremierSearch are package private.


OCPJP
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40061
    
  28
Please avoid misspelt words; people who did not grow up speaking English will find prob directoryy sryy etc very difficult to understand.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Java compilation error