Re: Cannot find symbol error
BoyerMooreImpl.java class as been extend the UnicastRemoteObject class or not & impliement the BoyerMoore.java class
it helps you i think so.
if problem is not solved then print the stracktrace of expection.
Re: Cannot find symbol error
I have done that before but i m getting the error given below....
I have also compiled all the files and all got compiled except BoyerMooreServer.java...
$ javac BoyerMooreServer.java
BoyerMooreServer.java:6: cannot find symbol
symbol : constructor BoyerMooreImpl(java.lang.String)
location: class BoyerMooreImpl
BoyerMooreImpl b= new BoyerMooreImpl("BoyerMooreServer");
^
1 error
Error is at new operator...
Re: Cannot find symbol error
I have done that before but i m getting the error given below....
I have also compiled all the files and all got compiled except BoyerMooreServer.java...
$ javac BoyerMooreServer.java
BoyerMooreServer.java:6: cannot find symbol
symbol : constructor BoyerMooreImpl(java.lang.String)
location: class BoyerMooreImpl
BoyerMooreImpl b= new BoyerMooreImpl("BoyerMooreServer");
^
1 error
Re: Cannot find symbol error
Show us the constructor of the BoyerMooreImpl class that takes a String parameter ...
kind regards,
Jos
Re: Cannot find symbol error
BoyerMooreImpl.java
import java.io.*;
import java.rmi.server.*;
import java.rmi.*;
public class BoyerMooreImpl extends UnicastRemoteObject
implements BoyerMoore {
private int R; // the radix
private int[] right; // the bad-character skip array
private char[] pattern; // store the pattern as a character array
private String pat;
// or as a string
public BoyerMooreImpl()
throws RemoteException {
super();
}
// pattern provided as a string
public int Bo(String pat) throws RemoteException {
this.R = 256;
this.pat = pat;
// position of rightmost occurrence of c in the pattern
right = new int[R];
for (int c = 0; c < R; c++)
right[c] = -1;
for (int j = 0; j < pat.length(); j++)
right[pat.charAt(j)] = j;
return 0;
}
// pattern provided as a character array
public void Bo(char[] pattern, int R) throws RemoteException{
this.R = R;
this.pattern = new char[pattern.length];
for (int j = 0; j < pattern.length; j++)
this.pattern[j] = pattern[j];
// position of rightmost occurrence of c in the pattern
right = new int[R];
for (int c = 0; c < R; c++)
right[c] = -1;
for (int j = 0; j < pattern.length; j++)
right[pattern[j]] = j;
}
// return offset of first match; N if no match
public int search(String txt) throws RemoteException{
int M = pat.length();
int N = txt.length();
int skip;
for (int i = 0; i <= N - M; i += skip) {
skip = 0;
for (int j = M-1; j >= 0; j--) {
if (pat.charAt(j) != txt.charAt(i+j)) {
skip = Math.max(1, j - right[txt.charAt(i+j)]);
break;
}
}
if (skip == 0) return i; // found
}
return N; // not found
}
// return offset of first match; N if no match
public int search(char[] text) throws RemoteException{
int M = pattern.length;
int N = text.length;
int skip;
for (int i = 0; i <= N - M; i += skip) {
skip = 0;
for (int j = M-1; j >= 0; j--) {
if (pattern[j] != text[i+j]) {
skip = Math.max(1, j - right[text[i+j]]);
break;
}
}
if (skip == 0)
{
System.out.println("Match found");
return i;
} // found
}
System.out.println("Match not found"); // not found
return N;
}
// test client
public static void main(String[] args) throws RemoteException {
System.setSecurityManager(new RMISecurityManager());
String pat = args[0];
String txt = args[1];
char[] pattern = pat.toCharArray();
char[] text = txt.toCharArray();
BoyerMooreImpl boyermoore1 = new BoyerMooreImpl();
boyermoore1.Bo(pat);
BoyerMooreImpl boyermoore2 = new BoyerMooreImpl();
boyermoore2.Bo(pattern,256);
int offset1 = boyermoore1.search(txt);
int offset2 = boyermoore2.search(text);
PrintStream StdOut = System.out;
// print results
StdOut.println("text: " + txt);
StdOut.print("pattern: ");
for (int i = 0; i < offset1; i++)
StdOut.print(" ");
StdOut.println(pat);
StdOut.print("pattern: ");
for (int i = 0; i < offset2; i++)
StdOut.print(" ");
StdOut.println(pat);
}
}
Re: Cannot find symbol error
See? There is no constructor in that class that takes a single String as its parameter. Problem solved ...
kind regards,
Jos
Re: Cannot find symbol error
So please tell me what shuld i do now...
i don't know what to insert and where to insert in the program...plese reply..
Re: Cannot find symbol error
Quote:
Originally Posted by
abdulahadone
So please tell me what shuld i do now...
i don't know what to insert and where to insert in the program...plese reply..
It's your code so you should know what to do: either create a constructor that takes a single String parameter or don't call it with such parameter and use the existing no-args constructor.
kind regards,
Jos
Re: Cannot find symbol error
You've managed to write that much code and you don't know how to write a constructor that takes a String parameter?
Crikey...
Re: Cannot find symbol error
Quote:
Originally Posted by
Tolls
You've managed to write that much code and you don't know how to write a constructor that takes a String parameter?
Crikey...
There are more things in heaven and earth Tolls; the code could've come to the OP in mysterious ways ...
kindest regards,
Jos ;-)
Re: Cannot find symbol error
Thanks jos...
Got it ...
I have excuted and got the result...