BufferedReader cannot resolve symbol
Hi,
I need some help with a java program which reads xml files to a specified location, running it on a UNIX machine using Java 1.4.1. I modified the code to include the BufferedReader class, but it keeps complaining about not being able to resolve symbol at line 50 & 53. Any help here would be appreciated, since I'm a newbie.
bash-2.05$ javac outputScript.java
outputScript.java:50: cannot resolve symbol
symbol : constructor InputStreamReader (java.lang.String)
location: class java.io.InputStreamReader
BufferedReader in = new BufferedReader(new InputStreamReader("in"));
^
outputScript.java:53: cannot resolve symbol
symbol : method available ()
location: class java.io.BufferedReader
while (in.available() !=0)
Here's the code:
//package cognos8_3;
import java.io.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.File;
* outputScript.java
* Copyright Cognos Incorporated. All Rights Reserved.
* Cognos and the Cognos logo are trademarks of Cognos Incorporated.
* Description: (KB 1013700) - Sample script that will rename output files generated by CM.OUTPUTLOCATION - Cognos 8.3
class outputScript
public static void main(String args[])
String reportName = "";
String reportViewName = "";
String outputLocation = "/data/cognos/rn_filecp/";
String defName = "";
String ofTime = "";
String burstKey = "";
int countRenamed = 0;
// get the list of desc files in the outputlocation
File descFiles = new File(outputLocation);
String[] children = descFiles.list();
if (children == null || children.length == 0)
System.out.println("Invalid file location or no reports found to rename.");
else
System.out.println("Found " + children.length + " files in this location, search for file names containing '_desc.'.");
for (int i=0; i<children.length; i++)
try
// Get filename of file or directory
String filename = children;
if (filename.indexOf("_desc.")>=0)
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream(outputLocation+filename);
FileInputStream bis = new FileInputStream(fstream);
BufferedReader in = new BufferedReader(new InputStreamReader("bis.in"));
// Continue to read lines while there are still some left to read
while (in.available() !=0)
String temp = in.readLine();
System.out.println(temp);
// check for report name
if (temp.indexOf("report[@name=")>0)
// get beginning of name
int startIndex = temp.indexOf("report[@name='");
String startString;
int endIndex = 0;
if (startIndex > 0)
startString = temp.substring(startIndex);
startIndex = startString.indexOf("'") + 5; //' 6 characters
endIndex = startString.lastIndexOf("'");
else
startIndex = temp.indexOf("report[@name=");
startString = temp.substring(startIndex);
startIndex = startString.indexOf("@name=") + 6; //' 6 characters
endIndex = startString.lastIndexOf("]");
// get report name
reportName = startString.substring(startIndex+1, endIndex);
//System.out.println("Found report name - " + reportName);
else if (temp.indexOf("reportView[@name=")>0)
// get beginning of name
int startIndex = temp.indexOf("reportView[@name='");
String startString;
int endIndex = 0;
if (startIndex > 0)
startString = temp.substring(startIndex);
startIndex = startString.indexOf("'") + 5; //' 6 characters
endIndex = startString.lastIndexOf("'");
else
startIndex = temp.indexOf("reportView[@name=");
startString = temp.substring(startIndex);
startIndex = startString.indexOf("@name=") + 6; //' 6 characters
endIndex = startString.lastIndexOf("]");
// get report name
reportViewName = startString.substring(startIndex+1, endIndex);
//System.out.println("Found reportView name - " + reportViewName);
else if (temp.indexOf("</fileName>")>0) //check for default name
defName = temp.substring(temp.indexOf(">")+1, temp.lastIndexOf("<"));
else if (temp.indexOf("asOfTime")>=0) // get the time to assure uniqueness when saving
ofTime = temp.substring(temp.indexOf(">")+1, temp.lastIndexOf("<"));
// clean colons from time
ofTime = ofTime.replaceAll(":","_");
else if (temp.indexOf("</burstKey>")>=0)
burstKey = temp.substring(temp.indexOf(">")+1, temp.lastIndexOf("<"));
in.close();
if (reportName.length() == 0)
reportName = reportViewName;
//System.out.println("Renaming using view name - no report name found");
String format = defName.substring(defName.length()-3, defName.length());
// new description xml file
File file = new File(outputLocation+filename);
File newDescFile = new File(outputLocation + reportName+"_"+burstKey+"_"+ofTime+"DESC_" + format+ ".xml");
// new renamed specific format file.
File file3 = new File(outputLocation+defName);
File newDefFile = new File(outputLocation + reportName+"_"+burstKey+"_"+ofTime+"."+format);
boolean success = file3.renameTo(newDefFile);
if (!success)
// File was not successfully renamed
System.out.println("ERROR attempting to rename - " + file3.getAbsolutePath() + " to \n\t\t" +
newDefFile.getAbsolutePath());
else
countRenamed++;
// File was successfully renamed
System.out.println(countRenamed +") Renamed - " + file3.getAbsolutePath() + " to \n\t\t" +
newDefFile.getAbsolutePath());
// Rename file (or directory)
success = file.renameTo(newDescFile);
if (!success)
// File was not successfully renamed
System.out.println("ERROR attempting to rename - " + file.getAbsolutePath() + " to \n\t\t" +
newDescFile.getAbsolutePath());
else
// File was successfully renamed
System.out.println(" - " + file.getAbsolutePath() + " to \n\t\t" +
newDescFile.getAbsolutePath());
catch (Exception e)
System.err.println("File input error " + e.getMessage()) ;
System.out.println("Complete.");
Thanks,
Nick
Edited by: nickmills on Aug 31, 2008 5:05 PM
First, you only need to create the FileInputStream once. Then that's what you pass to the InputStreamReader constructor. Your code for reading from the BufferedReader is also wrong.FileInputStream fstream = new FileInputStream(outputLocation+filename);
// FileInputStream bis = new FileInputStream(fstream); <-- remove this line
BufferedReader in = new BufferedReader(new InputStreamReader(fstream));
// available() doesn't do what you think it does; forget about it.
// Here's the standard way to use a BufferedReader
String line = null;
while ((line = in.readLine()) != null)
// process 'line'
} There are probably other errors in the code, but reading all that unformatted code is too much of a hassle. In future, please use {code} tags when posting source code.
Similar Messages
-
Class error - cannot resolve symbol "MyDocumentListener"
Hello,
this is a groaner I'm sure, but I don't see the problem.
Newbie-itis probably ...
I'm not concerned with what the class does, but it would be nice for the silly thing to compile!
What the heck am I missing for "MyDocumentListener" ?
C:\divelog>javac -classpath C:\ CenterPanel.java
CenterPanel.java:53: cannot resolve symbol
symbol : class MyDocumentListener
location: class divelog.CenterPanel
MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
^
CenterPanel.java:53: cannot resolve symbol
symbol : class MyDocumentListener
location: class divelog.CenterPanel
MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
^
2 errors
package divelog;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.text.*;
public class CenterPanel extends JPanel implements ActionListener
{ // Opens class
static private final String newline = "\n";
private JTextArea comments;
private JScrollPane scrollpane;
private JButton saveButton, openButton;
private JLabel whiteshark;
private Box box;
private BufferedReader br ;
private String str;
private JTextArea instruct;
private File defaultDirectory = new File("C://divelog");
private File fileDirectory = null;
private File currentFile= null;
public CenterPanel()
{ // open constructor CenterPanel
setBackground(Color.white);
comments = new JTextArea("Enter comments, such as " +
"location, water conditions, sea life you observed," +
" and problems you may have encountered.", 15, 10);
comments.setLineWrap(true);
comments.setWrapStyleWord(true);
comments.setEditable(true);
comments.setFont(new Font("Times-Roman", Font.PLAIN, 14));
// add a document listener for changes to the text,
// query before opening a new file to decide if we need to save changes.
MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
comments.getDocument().addDocumentListener(myDocumentListener); // create the reference for the class
// ------ Document listener class -----------
class MyDocumentListener implements DocumentListener {
public void insertUpdate(DocumentEvent e) {
Calculate(e);
public void removeUpdate(DocumentEvent e) {
Calculate(e);
public void changedUpdate(DocumentEvent e) {
private void Calculate(DocumentEvent e) {
// do something here
scrollpane = new JScrollPane(comments);
scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
saveButton = new JButton("Save Comments", new ImageIcon("images/Save16.gif"));
saveButton.addActionListener( this );
saveButton.setToolTipText("Click this button to save the current file.");
openButton = new JButton("Open File...", new ImageIcon("images/Open16.gif"));
openButton.addActionListener( this );
openButton.setToolTipText("Click this button to open a file.");
whiteshark = new JLabel("", new ImageIcon("images/gwhite.gif"), JLabel.CENTER);
Box boxH;
boxH = Box.createHorizontalBox();
boxH.add(openButton);
boxH.add(Box.createHorizontalStrut(15));
boxH.add(saveButton);
box = Box.createVerticalBox();
box.add(scrollpane);
box.add(Box.createVerticalStrut(10));
box.add(boxH);
box.add(Box.createVerticalStrut(15));
box.add(whiteshark);
add(box);
} // closes constructor CenterPanel
public void actionPerformed( ActionEvent evt )
{ // open method actionPerformed
JFileChooser jfc = new JFileChooser();
// these do not work !!
// -- set the file types to view --
// ExtensionFileFilter filter = new ExtensionFileFilter();
// FileFilter filter = new FileFilter();
//filter.addExtension("java");
//filter.addExtension("txt");
//filter.setDescription("Text & Java Files");
//jfc.setFileFilter(filter);
//Add a custom file filter and disable the default "Accept All" file filter.
jfc.addChoosableFileFilter(new JTFilter());
jfc.setAcceptAllFileFilterUsed(false);
// -- open the default directory --
// public void setCurrentDirectory(File dir)
// jfc.setCurrentDirectory(new File("C://divelog"));
jfc.setCurrentDirectory(defaultDirectory);
jfc.setSize(400, 300);
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
Container parent = saveButton.getParent();
//========================= Test Button Actions ================================
//========================= Open Button ================================
if (evt.getSource() == openButton)
int choice = jfc.showOpenDialog(CenterPanel.this);
File file = jfc.getSelectedFile();
/* a: */
if (file != null && choice == JFileChooser.APPROVE_OPTION)
String filename = jfc.getSelectedFile().getAbsolutePath();
// -- compare the currentFile to the file chosen, alert of loosing any changes to currentFile --
// If (currentFile != filename)
// -- get the current directory name -------
// public File getCurrentDirectory( );
File f=new File(System.getProperty("user.dir"));
fileDirectory = jfc.getCurrentDirectory();
// -- remember the last directory used --
if (defaultDirectory != fileDirectory)
{defaultDirectory = fileDirectory;}
try
{ //opens try
comments.getLineCount( );
// -- clear the old data before importing the new file --
comments.selectAll();
comments.replaceSelection("");
// -- get the new data ---
br = new BufferedReader (new FileReader(file));
while ((str = br.readLine()) != null)
{//opens while
comments.append(str);
} //closes while
} // close try
catch (IOException ioe)
{ // open catch
comments.append(newline +"Open command not successful:" + ioe + newline);
} // close catch
// ---- display the values of the directory variables -----------------------
comments.append(
newline + "The f directory variable contains: " + f +
newline + "The fileDirectory variable contains: " + fileDirectory +
newline + "The defaultDirectory variable contains: " + defaultDirectory );
else
comments.append("Open command cancelled by user." + newline);
} //close if statement /* a: */
//========================= Save Button ================================
} else if (evt.getSource() == saveButton)
int choice = jfc.showSaveDialog(CenterPanel.this);
if (choice == JFileChooser.APPROVE_OPTION)
File fileName = jfc.getSelectedFile();
// -- get the current directory name -------
// public File getCurrentDirectory( );
File f=new File(System.getProperty("user.dir"));
fileDirectory = jfc.getCurrentDirectory();
// -- remember the last directory used --
if (defaultDirectory != fileDirectory)
{defaultDirectory = fileDirectory;}
//check for existing files. Warn users & ask if they want to overwrite
for(int i = 0; i < fileName.length(); i ++) {
File tmp = null;
tmp = (fileName);
if (tmp.exists()) // display pop-up alert
//public static int showConfirmDialog( Component parentComponent,
// Object message,
// String title,
// int optionType,
// int messageType,
// Icon icon);
int confirm = JOptionPane.showConfirmDialog(null,
fileName + " already exists on " + fileDirectory
+ "\n \nContinue?", // msg
"Warning! Overwrite File!", // title
JOptionPane.OK_CANCEL_OPTION, // buttons displayed
// JOptionPane.ERROR_MESSAGE
// JOptionPane.INFORMATION_MESSAGE
// JOptionPane.PLAIN_MESSAGE
// JOptionPane.QUESTION_MESSAGE
JOptionPane.WARNING_MESSAGE,
null);
if (confirm != JOptionPane.YES_OPTION)
{ //user cancels the file overwrite.
try {
jfc.cancelSelection();
break;
catch(Exception e) {}
// ----- Save the file if everything is OK ----------------------------
try
{ // opens try
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
bw.write(comments.getText());
bw.flush();
bw.close();
comments.append( newline + newline + "Saving: " + fileName.getName() + "." + newline);
break;
} // closes try
catch (IOException ioe)
{ // open catch
comments.append(newline +"Save command unsuccessful:" + ioe + newline);
} // close catch
} // if exists
} //close for loop
else
comments.append("Save command cancelled by user." + newline);
} // end-if save button
} // close method actionPerformed
} //close constructor CenterPanel
} // Closes class CenterPanelThere is no way to be able to see MyDocumentListener class in the way you wrote. The reason is because MyDocumentListener class inside the constructor itself. MyDocumentListener class is an inner class, not suppose to be inside a constructor or a method. What you need to do is simple thing, just move it from inside the constructor and place it between two methods.
that's all folks
Qusay -
PLEASE HELP: cannot resolve symbol class
it's showing me the error on the following lines 7 and 9
it says cannot resolve symbol class Name and cannot resolve symbol class Phone
I also have a package name addressBook and it contains two files Entry.java and Address.java
Here is the code:
import java.io.*;
import addressBook.*;
public class AddressDr
public static void main(String[] args)throws IOException
Name name;
Address address;
Phone phone;
Entry entry;
String first, last, middle, street, city, state, zip;
int areaCode, number;
BufferedReader in;
in=new BufferedReader(new InputStreamReader(System.in));
PrintWriter outFile;
outFile=new PrintWriter(new FileWriter("Entries"));
System.out.println("Quit entered fot the first name ends the " + "application.");
System.out.print("Enter first name: ");
first=in.readLine();
while (first.compareTo("Quit") !=0)
System.out.print("Enter last name: ");
last=in.readLine();
System.out.print("Enter middle name: ");
middle=in.readLine();
name=new Name(first, last, middle);
System.out.print("Enter street address: ");
street=in.readLine();
System.out.print("Enter city: ");
city=in.readLine();
System.out.print("Enter state: ");
state=in.readLine();
System.out.print("Enter ZIP code: ");
zip=in.readLine();
address=new Address(street, city, state, zip);
System.out.print("Enter areaCode: ");
areaCode = Integer.parseInt(in.readLine());
System.out.print("Enter number: ");
number=Integer.parseInt(in.readLine());
phone=new Phone(areaCode, number);
entry= new Entry(name, address, phone);
entry.writeToFile(outFile);
System.out.print("Enter first name: ");
first=in.readLine();
outFile.close();
}OK. Here is how I did it.
I have AddressDr which is Address driver.
I have two files Address and Entry which in package addressBook.
AddressDr:
import java.io.*;
import addressBook.*;
public class AddressDr
public static void main(String[] args)throws IOException
Name name;
Address address;
Phone phone;
Entry entry;
String first, last, middle, street, city, state, zip;
int areaCode, number;
BufferedReader in;
in=new BufferedReader(new InputStreamReader(System.in));
PrintWriter outFile;
outFile=new PrintWriter(new FileWriter("Entries"));
System.out.println("Quit entered fot the first name ends the " + "application.");
System.out.print("Enter first name: ");
first=in.readLine();
while (first.compareTo("Quit") !=0)
System.out.print("Enter last name: ");
last=in.readLine();
System.out.print("Enter middle name: ");
middle=in.readLine();
name=new Name(first, last, middle);
System.out.print("Enter street address: ");
street=in.readLine();
System.out.print("Enter city: ");
city=in.readLine();
System.out.print("Enter state: ");
state=in.readLine();
System.out.print("Enter ZIP code: ");
zip=in.readLine();
address=new Address(street, city, state, zip);
System.out.print("Enter areaCode: ");
areaCode = Integer.parseInt(in.readLine());
System.out.print("Enter number: ");
number=Integer.parseInt(in.readLine());
phone=new Phone(areaCode, number);
entry= new Entry(name, address, phone);
entry.writeToFile(outFile);
System.out.print("Enter first name: ");
first=in.readLine();
outFile.close();
Entry:
package addressBook;
import java.io.*;
public class Entry
Name name;
Address address;
Phone phone;
public Entry(Name newName, Address newAddress, Phone phoneNumber)
name = newName;
address = newAddress;
phone = phoneNumber;
public Name knowName()
return name;
public Address knowAddress()
return address;
public Phone knowPhone()
return phone;
public void writeToFile(PrintWriter outFile)
outFile.println(name.knowFirstName());
outFile.println(name.knowLastName());
outFile.println(name.knowMiddleName());
oufFile.println(address.knowStreet());
outFile.println(address.knowState());
outFile.println(address.knowCity());
outFile.println(address.knowZip());
outFile.println(phone.knowAreaCode());
outFile.println(phone.knowDigits());
Address:
package addressBook;
public class Address
String street;
String city;
String state;
String zipCode;
public Address(String newStreet, String newCity, String newState, String zip)
street=newStreet;
city=newCity;
state=newState;
zipCode=zip;
public String knowStreet()
return street;
public String knowCity()
return city;
public String knowState()
return state;
public String knowZip()
return zipCode;
} -
Try/catch and 'cannot resolve symbol'
I am relatively new to java programming and something has me puzzled...
Why do I get a 'cannot resolve symbol' message when I include a variable definition in a try/catch section. When I put it/them before the 'try' statement it compiles as expected. How are statements inside a try compiled differently than those outside?
try {
StringBuffer pageBuffer = new StringBuffer();
String inputLine;
BufferedReader in = new BufferedReader(
new InputStreamReader( theURL.openStream() ) );
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
pageBuffer.append(inputLine);
in.close();
} catch (Exception ignored) {}C:\Projects\WebExplorer\PageVisitor.java:142: cannot resolve symbol
symbol : variable pageBuffer
location: class PageVisitor
return pageBuffer.toString();
PaulA try block is just like any other block delimited by {...} in that all variables declared inside it are local to that block. I.e. they are not visible or usable anywhere outside it. Your pageBuffer variable, for example, is a local variable that can only be used inside the try-block in which it is declared.
Your obvious solution, knowing that, is to declare the variables outside the try and catch blocks. Remember to initialize them (even to null), otherwise the compiler will complain about variables that may not have been initialized. -
Sequential.java [28:1] cannot resolve symbol
The program asks users to enter random numbers.They are stored in a vector. The numbers are then added and the results of the addition stored in an vector.ie
sum1=item1
sum2=item1+item2
sum3=item1+item2+item3
sumn=item1+item2+,,,,,+itemn
here is the program
import java.util.Vector;
import java.io.*;
public class Sequential {
/** Creates a new instance of Sequential */
public Sequential() {
public static int inputInt(String str){
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.println(str);
int val;
try{
val = Integer.parseInt(input.readLine());
}catch(Exception e){}
return val;
public static void main (String args[]){
//initialising
Vector myarray = new Vector();
Vector sum = new Vector();
int ans = 0;
int dim;
dim = inputInt("Enter the array dimension");
//populate the
for(int i=0; i < dim; i++){
myarray.add(i,inputInt("Enter the array dimension"));
for(int i=0; i < dim; i++ ){
ans = Integer.parseInt(myarray.get(i)) + ans;
sum.add(i,ans);
for(int i=0; i < dim; i++){
System.out.println("Item [" + i + "] is " + sum.get(i));
it dispalys on ".add" part
Sequential.java [28:1] cannot resolve symbol in
myarray.add(i,inputInt("Enter the array dimension"));Vectors store objects, not primitives.
Try the Integer wrapper class, e.g. myarray.add(i, new Integer(inputInt("Enter the array dimension")));
There are some other code problems I think you'll notice, but you should be able to work those out. -
Cannot resolve symbol error while trying to define methods in a class
Well, I'm fairly new to java and I'm trying to write a simple program that will take user input for up to 100 die and how many sides they have and will then roll them and output the frequencies of numbers occuring. I have overloaded the constructor for the Die class to reflect different choices the user may have when initializing the Die.
Here is my code:import java.util.*;
import java.io.*;
public class Die
private final int MIN_FACES = 4;
private int numFaces;
private int i = 0;
private int faceValue;
private Die currentDie;
private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private String line = null;
public Die()
numFaces = 6;
faceValue = 1;
public Die (int faces)
if (faces < MIN_FACES) {
numFaces = 6;
System.out.println ("Minimum number of faces allowed is 6.");
System.out.println ("Setting faces to 6... . . . . . . . . .");
else
numFaces = faces;
faceValue = 1;
//Returns an array of Die Objects
public Die (int num_die, int faces)
numFaces = faces;
Die[] protoDie = new Die[num_die];
for (i = 0; i <= num_die-1; i++)
Die currentDie = new Die(numFaces);
protoDie = protoDie.initMultiDie(currentDie, i);
public Die (double num_die)
int numberOfDie = (int) num_die;
Die[] protoDie = new Die[numberOfDie];
System.out.print ("Enter the number of sides for die #" + i);
for (i=0; i <= protoDie.length; i++) {
do {
try {
line = br.readLine();
numFaces = Integer.parseInt(line);
catch (NumberFormatException nfe) {
System.out.println ("You must enter an integer.");
System.out.print ("Setting number of dice to 0, please reenter: ");
if (numFaces < 0) {
System.out.println ("The number of sides must be positive.");
numFaces *= -1;
System.out.println ("Number of sides is: " + numFaces);
else
if (numFaces = 0) {
System.out.println ("Zero dice is no fun. =[");
System.out.print ("Please reenter the number of sides: ");
numFaces = 0;
while (numFaces == 0);
Die currentDie = new Die(numFaces);
protoDie[i] = protoDie.initMultiDie(currentDie, i);
i = 0;
public Die[] initMultiDie (Die[] protoDie, Die currentDie, int i)
protoDie[i] = currentDie;
return protoDie;
public Die reInit (int sides)
currentDie.roll();
return currentDie;
public int roll()
faceValue = (int) (Math.random() * numFaces) + 1;
return faceValue;
}When I compile I get 2 errors at lines 42 and 73 saying:
Cannot resolve symbol | symbol: method initMultiDie(Die, int) | location: class Die[] | protoDie[i] = protoDie.initMultiDie(currentDie, i)
I've tried mixing things up with invoking the method, such as including protoDie in the parameter liist, instead of invoking the initMultiDie method thru the protoDie Die[] object. I'm a little confused as to what I can and cannot do with defining arrays of Objects like Die. Thank you for any input you may be able to provide.
~LijeI may as well just replace Die with Dice and allow
Dice to represent a collection of 1 die.. I just like
to cut on bloat and make my programs be as efficient
as possible.Efficiency and avoiding code bloat are good goals, but you don't necessarily achieve it by creating the smallest number of classes. If you have N algorithms in M lines, then you have that many, regardless of whether they're in one class or two. A really long source file can be a worse example of bloat than two source files of half the size -- it can be harder to read, less clear in the design, and thus with more bugs...
The important thing is clarity and a strong design.
The weird thing is, that initMultiDie is
what seems to be throwing up the error, but I don't
see why. Meh, I'm sure I'll figure it out.Refactoring a class to make the design more transparent often helps you figure out bugs. -
Cannot find package error and cannot resolve symbol error
Hi
I have a file Assignment.java in C:\TIJCode\c03 folder. But this file belongs to the default package. This file imports a package com.bruceeckel.simpletest which is in C:\TIJCode\ folder. Now this package has a file named Test.java which accesses a few more files fromt he same package.
I set the classpath to C:\TIJCode. When i try to run the Assignment file I get an error saying package com.bruceeckel.simpletest cannot be found and cannot resolve symbol error. symbol: Test Class: Assignment.
The files in com.bruceeckel.simpletest package were not compiled. So I first tried to do that. But I get a cannot resolve symbol error while trying to compile a file NumOfLinesException which inherits SImpleTestException file. The exact error message is
NumOfLinesException.java : 7 : cannot resolve symbol
symbol : class SimpleTestException
location : class com.bruceeckel.simpletest.NumOfLinesException extends SimpleTestException
The exact code in each of above mentioned files is
//: c03:Assignment.java
// Assignment with objects is a bit tricky.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
import com.bruceeckel.simpletest.*;
class Number {
int i;
public class Assignment {
static Test monitor = new Test();
public static void main(String[] args) {
Number n1 = new Number();
Number n2 = new Number();
n1.i = 9;
n2.i = 47;
System.out.println("1: n1.i: " + n1.i +
", n2.i: " + n2.i);
n1 = n2;
System.out.println("2: n1.i: " + n1.i +
", n2.i: " + n2.i);
n1.i = 27;
System.out.println("3: n1.i: " + n1.i +
", n2.i: " + n2.i);
monitor.expect(new String[] {
"1: n1.i: 9, n2.i: 47",
"2: n1.i: 47, n2.i: 47",
"3: n1.i: 27, n2.i: 27"
} ///:~
//: com:bruceeckel:simpletest:SimpleTestException.java
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
package com.bruceeckel.simpletest;
public class SimpleTestException extends RuntimeException {
public SimpleTestException(String msg) {
super(msg);
} ///:~
//: com:bruceeckel:simpletest:NumOfLinesException.java
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
package com.bruceeckel.simpletest;
public class NumOfLinesException extends SimpleTestException {
public NumOfLinesException(int exp, int out) {
super("Number of lines of output and "
+ "expected output did not match.\n" +
"expected: <" + exp + ">\n" +
"output: <" + out + "> lines)");
} ///:~
//: com:bruceeckel:simpletest:Test.java
// Simple utility for testing program output. Intercepts
// System.out to print both to the console and a buffer.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
package com.bruceeckel.simpletest;
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class Test {
// Bit-shifted so they can be added together:
public static final int
EXACT = 1 << 0, // Lines must match exactly
AT_LEAST = 1 << 1, // Must be at least these lines
IGNORE_ORDER = 1 << 2, // Ignore line order
WAIT = 1 << 3; // Delay until all lines are output
private String className;
private TestStream testStream;
public Test() {
// Discover the name of the class this
// object was created within:
className =
new Throwable().getStackTrace()[1].getClassName();
testStream = new TestStream(className);
public static List fileToList(String fname) {
ArrayList list = new ArrayList();
try {
BufferedReader in =
new BufferedReader(new FileReader(fname));
try {
String line;
while((line = in.readLine()) != null) {
if(fname.endsWith(".txt"))
list.add(line);
else
list.add(new TestExpression(line));
} finally {
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
return list;
public static List arrayToList(Object[] array) {
List l = new ArrayList();
for(int i = 0; i < array.length; i++) {
if(array[i] instanceof TestExpression) {
TestExpression re = (TestExpression)array;
for(int j = 0; j < re.getNumber(); j++)
l.add(re);
} else {
l.add(new TestExpression(array[i].toString()));
return l;
public void expect(Object[] exp, int flags) {
if((flags & WAIT) != 0)
while(testStream.numOfLines < exp.length) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
List output = fileToList(className + "Output.txt");
if((flags & IGNORE_ORDER) == IGNORE_ORDER)
OutputVerifier.verifyIgnoreOrder(output, exp);
else if((flags & AT_LEAST) == AT_LEAST)
OutputVerifier.verifyAtLeast(output,
arrayToList(exp));
else
OutputVerifier.verify(output, arrayToList(exp));
// Clean up the output file - see c06:Detergent.java
testStream.openOutputFile();
public void expect(Object[] expected) {
expect(expected, EXACT);
public void expect(Object[] expectFirst,
String fname, int flags) {
List expected = fileToList(fname);
for(int i = 0; i < expectFirst.length; i++)
expected.add(i, expectFirst[i]);
expect(expected.toArray(), flags);
public void expect(Object[] expectFirst, String fname) {
expect(expectFirst, fname, EXACT);
public void expect(String fname) {
expect(new Object[] {}, fname, EXACT);
} ///:~What do you have in the C:\TIJCode\ directory? Does the directory structure mimic the package structure for the stuff you're importing?
-
'Cannot Resolve Symbol' error when importing custom class
I get this error...
c:\mydocu~1\n307\auto.java:14: cannot resolve symbol
symbol: class Box
import Box;
^
when I try to compile auto.java, the applet that's supposed to import the class Box, which I built to be like a message box in VB. Here is the code for Box...
import java.awt.*;
import java.awt.event.*;
public class Box extends Window{
Label lblMsg = new Label();
Button cmdOk = new Button("OK");
Panel pnlSouth = new Panel();
EventHandler ehdlr=new EventHandler(this);
public Box(Frame parent){
super(parent);
setLayout(new BorderLayout());
add(lblMsg, BorderLayout.NORTH);
add(pnlSouth, BorderLayout.SOUTH);
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(cmdOk);
cmdOk.addActionListener(ehdlr);
this.addWindowListener(ehdlr);
public void speak(String msg){
lblMsg.setText(msg);
this.setLocation(200,200);
this.setSize(200,200);
this.setVisible(true);
private class EventHandler extends WindowAdapter
implements ActionListener{
Window theWindow;
public EventHandler(Window a){
theWindow=a;
public void actionPerformed(ActionEvent e){
theWindow.setVisible(false);
AND HERE IS THE CODE FOR AUTO...
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import Box;
public class auto extends Applet implements ActionListener{
Panel pnlCenter=new Panel();
Panel pnlSouth=new Panel();
Panel pnlNorth=new Panel();
Panel pnlCenterleft=new Panel();
Panel pnlCenterright=new Panel();
Button cmdSubmit=new Button("Submit");
Button cmdNext=new Button("Next");
Button cmdPrev=new Button("Previous");
Label lblLoc=new Label("LOCATION:");
Label lblDate=new Label("DATE:");
Label lblMile=new Label("MILEAGE:");
Label lblCost=new Label("COST:");
Label lblDesc=new Label("DESCRIPTION:");
Label lblFind=new Label("FIND LOCATION:");
Label lblDisp=new Label();
TextField txtLoc=new TextField();
TextField txtDate=new TextField();
TextField txtMile=new TextField();
TextField txtCost=new TextField();
TextArea txtDesc=new TextArea();
TextField txtFind=new TextField();
Box bxOne = new Box((Frame(this).getParent()));
/*by declaring these four variables here, they are instance level, meaning they are
available to the whole applet*/
String textFile="auto.txt";
String list[] = new String[100];
String sort[] = new String[100];
int counter=0;
int count=0;
String currentLine="";
int i;
int sortcount;
public void init(){
this.setLayout(new BorderLayout());
this.add(pnlNorth, BorderLayout.NORTH);
this.add(pnlCenter, BorderLayout.CENTER);
this.add(pnlSouth, BorderLayout.SOUTH);
pnlNorth.setLayout(new FlowLayout());
pnlNorth.add(new Label("VIEW RECORDS"));
pnlCenter.setLayout(new GridLayout(1,2));
pnlCenter.add(pnlCenterleft);
pnlCenter.add(pnlCenterright);
pnlCenterleft.setLayout(new GridLayout(0,1));
pnlCenterleft.add(lblLoc);
pnlCenterleft.add(lblDate);
pnlCenterleft.add(lblMile);
pnlCenterleft.add(lblCost);
pnlCenterleft.add(lblDesc);
pnlCenterleft.add(lblFind);
pnlCenterright.setLayout(new GridLayout(0,1));
pnlCenterright.add(txtLoc);
pnlCenterright.add(txtDate);
pnlCenterright.add(txtMile);
pnlCenterright.add(txtCost);
pnlCenterright.add(txtDesc);
pnlCenterright.add(txtFind);
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(cmdPrev);
pnlSouth.add(lblDisp);
pnlSouth.add(cmdSubmit);
pnlSouth.add(cmdNext);
lblDisp.setText("0 of 0");
cmdPrev.addActionListener(this);
cmdNext.addActionListener(this);
cmdSubmit.addActionListener(this);
public void actionPerformed(ActionEvent e){
String command=e.getActionCommand();
if (command.equals("Next")){
if(txtLoc.getText().equals("")){
reader();
transfer();
writer();
bxOne.speak("Viewing all records");
}else{
if(counter<count-2){
counter++;
writer();
}else{
//don't move
} else if (command.equals("Previous")){
if(txtLoc.getText().equals("")){
//do nothing
}else{
if(counter>0){
counter--;
writer();
}else{
//don't move
} else {
txtLoc.setText("");
txtDate.setText("");
txtMile.setText("");
txtCost.setText("");
txtDesc.setText("");
reader();
sorter();
writer();
private void writer(){
StringTokenizer stCurrent=new StringTokenizer(sort[counter], "\t");
txtLoc.setText(stCurrent.nextToken());
txtDate.setText(stCurrent.nextToken());
txtMile.setText(stCurrent.nextToken());
txtCost.setText(stCurrent.nextToken());
txtDesc.setText(stCurrent.nextToken());
lblDisp.setText(String.valueOf(counter+1) + " of " + String.valueOf(count-1));
private void reader(){
try{
URL textURL=new URL(getDocumentBase(), textFile);
InputStream issIn=textURL.openStream();
InputStreamReader isrIn=new InputStreamReader(issIn);
BufferedReader brIn=new BufferedReader(isrIn);
while(currentLine!=null){
currentLine=brIn.readLine();
list[count]=currentLine;
count++;
}catch(MalformedURLException exc){
System.out.println("MalformedURLException Error");
}catch(IOException exc){
System.out.println("IOException Error");
}catch(NullPointerException exc){
System.out.println("NullPointerException Error");
private void transfer(){
for(i=0;i<count;i++){
sort=list[i];
private void sorter(){
sortcount=0;
String find=txtFind.getText();
System.out.println(String.valueOf(count));
for(i=0;i<count-1;i++){
StringTokenizer st=new StringTokenizer(list[i], "\t");
String next=st.nextToken();
if (find.equals(next)){
sort[sortcount]=list[i];
sortcount++;
count=sortcount+1;
Any help is greatly appreciated.
2Willis4Hi agian,
I looked closer at your code, I think if you play around with directories and paths, you'll get it, and I think also when you import, you have to have put the class in a package...? Maybe? Blind leading the blind here! So at the top of your box class you have to say something like
package org.blah.lala
and you have to have that directory structure for the class files org/blah/lala/Box.class
Does that make sense?
And then when you import you say:
import org.blah.lala.Box
(I think)
I cna only imagine that this 'help' I am giving you would be hilarious to a more experienced programmer!
Anyway, best of luck. -
Visual Studio 2012 cannot resolve symbol or Errors control is not a member of class
Visual Studio 2012 Web Site Project (Note not a Web application, so there are not Designer.vb files) > Site works perfectly fine and using IIS and attaching to IIS to debug code.
However, if I try to build the site inside of Visual Studio I am getting lots of Errors ‘pnlName’ is not a member of ‘Page_Name’ In the code behind I am getting errors ‘Cannot resolve symbol ‘pnlName’
.ascx Page
<li style="margin-right:0;" id="pnlName" runat="server"><a href="/cart" title="Checkout" class="global-checkout">Checkout</a></li>
.ascx.vb page
Me.pnlName.Attributes.Remove("style")
I have cleaned, rebuild and nothing gets rid of these errors, but again the site works as designed, but I would like to launch and debug inside of Visual Studio.
Moojjoo MCP, MCTS
MCP Virtual Business Card
http://moojjoo.blogspot.comCor,
What I am stating is this is a solution using the Web Site Project instead of a
Web Application Project.
Web Site projects do not require Designer.vb files, Web Application Projects add Designer.vb files in the solution.
Background: I have been hired to support a very successful e-commerce site that was built by a 3rd party vendor (I had no input on the contract or specification, because I would have went with
MVC). The site works 100% correctly, however from my 2003 - 2015 experience with Visual Studio and Web Development being in Web Forms and MVC I have always built ASP.NET Solutions using the Web Application Project Templates, which compiles the code down
to .dlls.
A Web Site project does not compile the code, but simply uses the .vb files and they have to be migrated to the server with the .aspx files. http://msdn.microsoft.com/en-us/library/dd547590%28v=vs.110%29.aspx
Currently the only way I can debug this Solution is to attach to the w3wp.exe process running locally on my work station.
The Solution is comprised of two Web Sites, which I cannot get it to compile because of the following errors -
'webServerControlName' is not a member of '(Protected Code Behind Class Name)' I am reaching out to the MSDN community to see if anyone has experienced this issue with
Web Site Projects.
I hope that clears up the Project Type question.
Moojjoo MCP, MCTS
MCP Virtual Business Card
http://moojjoo.blogspot.com -
Getting error message Cannot Resolve Symbol when trying to compile a class
Hello All -
I am getting an error message cannot resolve symbol while trying to compile a java class that calls another java class in the same package. The called class compiles fine, but the calling class generates
the following error message:
D:\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes\cal>javac
ConnectionPool.java
ConnectionPool.java:158: cannot resolve symbol
symbol : class PooledConnection
location: class cal.ConnectionPool
private void addConnection(PooledConnection value) {
^
ConnectionPool.java:144: cannot resolve symbol
symbol : class PooledConnection
location: class cal.ConnectionPool
PooledConnection pcon = new PooledConnection(con);
^
ConnectionPool.java:144: cannot resolve symbol
symbol : class PooledConnection
location: class cal.ConnectionPool
PooledConnection pcon = new PooledConnection(con);
The code is listed as follows for PooledConnection.java (it compiles fine)
package cal;
import java.sql.*;
public class PooledConnection {
// Real JDBC Connection
private Connection connection = null;
// boolean flag used to determine if connection is in use
private boolean inuse = false;
// Constructor that takes the passed in JDBC Connection
// and stores it in the connection attribute.
public PooledConnection(Connection value) {
if ( value != null ) {
connection = value;
// Returns a reference to the JDBC Connection
public Connection getConnection() {
// get the JDBC Connection
return connection;
// Set the status of the PooledConnection.
public void setInUse(boolean value) {
inuse = value;
// Returns the current status of the PooledConnection.
public boolean inUse() {
return inuse;
// Close the real JDBC Connection
public void close() {
try {
connection.close();
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
Now the code for ConnectionPool.java class that gives the cannot
resolve symbol error
package cal;
import java.sql.*;
import java.util.*;
public class ConnectionPool {
// JDBC Driver Name
private String driver = null;
// URL of database
private String url = null;
// Initial number of connections.
private int size = 0;
// Username
private String username = new String("");
// Password
private String password = new String("");
// Vector of JDBC Connections
private Vector pool = null;
public ConnectionPool() {
// Set the value of the JDBC Driver
public void setDriver(String value) {
if ( value != null ) {
driver = value;
// Get the value of the JDBC Driver
public String getDriver() {
return driver;
// Set the URL Pointing to the Datasource
public void setURL(String value ) {
if ( value != null ) {
url = value;
// Get the URL Pointing to the Datasource
public String getURL() {
return url;
// Set the initial number of connections
public void setSize(int value) {
if ( value > 1 ) {
size = value;
// Get the initial number of connections
public int getSize() {
return size;
// Set the username
public void setUsername(String value) {
if ( value != null ) {
username = value;
// Get the username
public String getUserName() {
return username;
// Set the password
public void setPassword(String value) {
if ( value != null ) {
password = value;
// Get the password
public String getPassword() {
return password;
// Creates and returns a connection
private Connection createConnection() throws Exception {
Connection con = null;
// Create a Connection
con = DriverManager.getConnection(url,
username, password);
return con;
// Initialize the pool
public synchronized void initializePool() throws Exception {
// Check our initial values
if ( driver == null ) {
throw new Exception("No Driver Name Specified!");
if ( url == null ) {
throw new Exception("No URL Specified!");
if ( size < 1 ) {
throw new Exception("Pool size is less than 1!");
// Create the Connections
try {
// Load the Driver class file
Class.forName(driver);
// Create Connections based on the size member
for ( int x = 0; x < size; x++ ) {
Connection con = createConnection();
if ( con != null ) {
// Create a PooledConnection to encapsulate the
// real JDBC Connection
PooledConnection pcon = new PooledConnection(con);
// Add the Connection to the pool.
addConnection(pcon);
catch (Exception e) {
System.err.println(e.getMessage());
throw new Exception(e.getMessage());
// Adds the PooledConnection to the pool
private void addConnection(PooledConnection value) {
// If the pool is null, create a new vector
// with the initial size of "size"
if ( pool == null ) {
pool = new Vector(size);
// Add the PooledConnection Object to the vector
pool.addElement(value);
public synchronized void releaseConnection(Connection con) {
// find the PooledConnection Object
for ( int x = 0; x < pool.size(); x++ ) {
PooledConnection pcon =
(PooledConnection)pool.elementAt(x);
// Check for correct Connection
if ( pcon.getConnection() == con ) {
System.err.println("Releasing Connection " + x);
// Set its inuse attribute to false, which
// releases it for use
pcon.setInUse(false);
break;
// Find an available connection
public synchronized Connection getConnection()
throws Exception {
PooledConnection pcon = null;
// find a connection not in use
for ( int x = 0; x < pool.size(); x++ ) {
pcon = (PooledConnection)pool.elementAt(x);
// Check to see if the Connection is in use
if ( pcon.inUse() == false ) {
// Mark it as in use
pcon.setInUse(true);
// return the JDBC Connection stored in the
// PooledConnection object
return pcon.getConnection();
// Could not find a free connection,
// create and add a new one
try {
// Create a new JDBC Connection
Connection con = createConnection();
// Create a new PooledConnection, passing it the JDBC
// Connection
pcon = new PooledConnection(con);
// Mark the connection as in use
pcon.setInUse(true);
// Add the new PooledConnection object to the pool
pool.addElement(pcon);
catch (Exception e) {
System.err.println(e.getMessage());
throw new Exception(e.getMessage());
// return the new Connection
return pcon.getConnection();
// When shutting down the pool, you need to first empty it.
public synchronized void emptyPool() {
// Iterate over the entire pool closing the
// JDBC Connections.
for ( int x = 0; x < pool.size(); x++ ) {
System.err.println("Closing JDBC Connection " + x);
PooledConnection pcon =
(PooledConnection)pool.elementAt(x);
// If the PooledConnection is not in use, close it
if ( pcon.inUse() == false ) {
pcon.close();
else {
// If it is still in use, sleep for 30 seconds and
// force close.
try {
java.lang.Thread.sleep(30000);
pcon.close();
catch (InterruptedException ie) {
System.err.println(ie.getMessage());
I am using Sun JDK Version 1.3.0_02" and Apache/Tomcat 4.0. Both the calling and the called class are in the same directory.
Any help would be greatly appreciated.
tnx..
addiIs ConnectionPool in this "cal" package as well as PooledConnection? From the directory you are compiling from it appears that it is. If it is, then you are compiling it incorrectly. To compile ConnectionPool (and PooledConnection similarly), you must change the current directory to the one that contains cal and type
javac cal/ConnectionPool. -
Missing method body and cannot resolve symbol
I keep getting these two errors when trying to compile. I know that I need to call my fibonacci and factorial functions from the main function. Is this why I am getting the missing method body error? How do I correct this?
Am I getting the cannot resolve symbol because I have to set the num and fact to equal something?
Thanks
public class Firstassignment
public static void main(String[]args)
System.out.println();
public static void fibonacci(String[]args);
int even=1;
int odd=1;
while (odd<=100);
System.out.println(even);
int temp = even;
even = odd;
odd = odd + temp;
public static void factorial (String[]args);
for (int count=1;
count<=num;
count++);
fact = fact * count;
outputbox.printLine("Factorial of" + num + "is" + fact);Hey... :o)
the problem is that you've put semicolons at the end of the function signature, like this:
public static void fibonacci(String[]args);
}that should happen only when the function is abstract... so ur function should actually look like this:
public static void fibonacci(String[]args)
}also, i think you've missed out on the declarations (like what are fact and num??).... -
"cannot resolve symbol" in a Timer !!!Please Help!!!
I am doing a program for a class which involves timers. I am using JCreator and when i try to construct a new timer, the compiler points to the "new" in the line:
Timer T1=new Timer(interval, ActionListener);
^
This is what it looks like and the error reads: cannot resolve symbol; constructor Timer.
please tell me if yiou have any information or suggestions as to how this error might be remedied.Sure, here it is:
import java.awt.event.*;
import javax.swing.Timer;
import javax.swing.JOptionPane;
import java.util.*;
interface ActionListener
void actionPerformed(ActionEvent event);
class Ploid
public static void main(String[] args)
class Car implements ActionListener
int mpg=30;
int mph=35;
int gtank=20;
int interval;
int changer;
int totalmiles;
Car(int x)
interval=x;
public void actionPerformed(ActionEvent event)
for(int c=0;c<(interval/1000);c++)
totalmiles=totalmiles+mph;
int hyt=mpg*gtank;
if(totalmiles>hyt)
int y=totalmiles-hyt;
totalmiles=totalmiles-y;
System.out.println(totalmiles);
else
System.out.println(totalmiles);
class SUV implements ActionListener
int mpg=15;
int mph=55;
int gtank=30;
int interval;
int changer;
int totalmiles;
SUV(int x)
interval=x;
public void actionPerformed(ActionEvent event)
for(int c=0;c<(interval/1000);c++)
totalmiles=totalmiles+mph;
int hyt=mpg*gtank;
if(totalmiles>hyt)
int y=totalmiles-hyt;
totalmiles=totalmiles-y;
System.out.println(totalmiles);
else
System.out.println(totalmiles);
class Semi implements ActionListener
int mpg=60;
int mph=80;
int gtank=50;
int interval;
int changer;
int totalmiles;
Semi(int x)
interval=x;
public void actionPerformed(ActionEvent event)
for(int c=0;c<(interval/1000);c++)
totalmiles=totalmiles+mph;
int hyt=mpg*gtank;
if(totalmiles>hyt)
int y=totalmiles-hyt;
totalmiles=totalmiles-y;
System.out.println(totalmiles);
else
System.out.println(totalmiles);
String flag="y";
String trav=JOptionPane.showInputDialog("How long do you want to drive?(1000=1 hour)");
int t1=Integer.parseInt(trav);
Car listen=new Car(t1);
SUV listener2=new SUV(t1);
Semi listener3=new Semi(t1);
final int t2=t1/1000;
final int t3=t1/t2;
ActionListener listener=null;
Timer T1=new Timer(t3, listener);
Timer T2=new Timer(t3, listener);
Timer T3=new Timer(t3, listener);
while(flag.equals("y"))
T1.start();
T2.start();
T3.start();
String g=JOptionPane.showInputDialog("Do you want to drive again?");
if((g.equals("y"))||(g.equals("Y")))
System.out.println("Let's Drive!");
else
flag=g;
System.exit(0);
}Here is the errors:
[errors]
A:\Ploid2.java:116: cannot resolve symbol
symbol : constructor Timer (int,ActionListener)
location: class javax.swing.Timer
Timer T1=new Timer(t3, listener);
^
A:\Ploid2.java:117: cannot resolve symbol
symbol : constructor Timer (int,ActionListener)
location: class javax.swing.Timer
Timer T2=new Timer(t3, listener);
^
A:\Ploid2.java:118: cannot resolve symbol
symbol : constructor Timer (int,ActionListener)
location: class javax.swing.Timer
Timer T3=new Timer(t3, listener);
^
3 errors
Process completed.
[errors]
****There is the source code and the errors the compiler returns. That should be more help.**** -
Recieving cannot resolve symbol symbol : class Serializable
I'm receiving the error:
cannot resolve symbol symbol : class Serializable
The class is as follows:
//package cscie160.hw5;
import java.io.Serializable
* @author Eddie Brodie
* @version %I%, %G%
public class AccountInfo implements Serializable
public int _accountNumber;
public int _pin;
public AccountInfo(int accountNumber, int pin)
_accountNumber = accountNumber;
_pin = pin;
I've tried importing java.*
I've also checked my classpath.
Any ideas?Try taking the import statement out of the comment block; that might help
-
Cannot resolve symbol: class OracleDriver
Attempting to compile a servlet on Apache Server using same jdeveloper jdbc libraries:
classes12.jar & nls_charset12.jar
Error message:
$compilejava2.sh ProdJobs
ProdJobs.java:361: cannot resolve symbol
symbol : class OracleDriver
location: package driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Am I missing something else?
JeffreyEnter this code into your program and then put the Oracle jar file that contains the driver in your run-time classpath.
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(ClassNotFoundException cnfe) {
// driver not found
}The effect of this is that the classloader will load the Oracle driver for you then call it's static initiailizer that does a bunch of magic that results in the Java runtime knowing that there's a JDBC driver out there.
It is a little weird - but that's the way it works. -
Cannot resolve symbol: class EJBObject
Using javac I get this compile error on this file Calculator.java
Calculator.java:1: cannot resolve symbol
symbol : class EJBObject
location: package ejb
import javax.ejb.EJBObject;
^
Calculator.java:5: cannot resolve symbol
symbol : class EJBObject
location: interface Calculator
public interface Calculator extends EJBObject {
Source code for Calculator.java
import javax.ejb.EJBObject;
import java.rmi.*;
public interface Calculator extends EJBObject {
public long add (int x, int y) throws RemoteException;
public long subtract (int x, int y) throws RemoteException;This code is from a book, so I will assume its a classpath problem. My
classpath looks like:
"C\QTJava.zip".;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib\locale
Also the following enviorment varibales have been set to:
J2EE_HOME
C:\Development\Java\j2sdkee1.3.1
JAVA_HOME
C:\Development\Java\jdk1.3.1
Path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;%JAVA_HOME%\bin;%J2EE_HOME%\bin
I can run j2EE, like "j2EE -verbose" (no problems)
also run cloudscape, like "cloudscape -start" (no problems)
also can run deploytool, like "deploytool" (no problems, & deploy sample ear files from cd book)
Your help is appreicated.
Maybe you are looking for
-
Hi gurus, can any body explain me abt returns process to vendor in the material management. Thanks in advance.. regards, vikram.
-
My system perically locks up with the color ball spinning. I manually have to turn it off and back on to unlock it. I have use the Mackeeper to clean out junk fuile whuich most of the time is none but the problem continues. cmdrgordon
-
SSH-4-SSH2_UNEXPECTED_MSG
Ok, I need a little help with this logging that i found on our production router. This is the message I am starting to get in my logging for the router Another FIN in CLOSEWAIT state. %SSH-4-SSH2_UNEXPECTED_MSG: Unexpected message type has arrived.
-
Mismatch in InStock Quantity in Item Master at Item level and W/H Level
Hi, All, I get some mismatch in 'InStock Quantity' at Item level and W/H Level, in Item Master. for Some Item and mismatch increases day by day. ex: At one total item Instock Qty : 100 but in W/H 1
-
I am concern that in finder shows that someone else is sharing my computer, how can I delete that ? or block any sharing in the future?