File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with Java compilation error

 
sailaja cherukuri
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1158
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
sailaja cherukuri
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1158
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 384
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sailaja,

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

 
sailaja cherukuri
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package example;

class calculator
{
public static void main(String args[])
{
System.out.println("this is a package example");
}
}
 
sailaja cherukuri
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 679
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1158
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But from where / which directory are you executing this command?
 
Ishan Pandya
Ranch Hand
Posts: 225
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please avoid misspelt words; people who did not grow up speaking English will find prob directoryy sryy etc very difficult to understand.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic