Yet another cannot resolve symbol
I'm having a similar problem to many others that have posted here but having tried every suggestion I'm still stuck.
My Platform: java 2 1.4.1_01 on WinNT 4.0 SP 6a.
I've created a class Career which compiles without any problems. I have also created a CareerList class which takes an array of Career objects as an attribute, and it's here that the 'cannot resolve symbol' error occurs.
CareerList.java:10: cannot resolve symbol
symbol : class Career
location: class CareerList
private Career[] careers;
I have calls to Career objects occuring 4 times within CareerList and get this error occurs wherever the Career class is called, whether it's an array or an individual object.
It appears that it cannot find the Career class, although it is there. I am running javac from the directory where all the required classes are held and have also tinkered with the classpath settings.
I have set the Path variable inside the System Variables to point to <java_home>\bin, and have also tried setting the CLASSPATH inside User Variables to the directory where the class files are stored. This has not solved the problem.
There does not appear to be any typo's within the code.
Any ideas what it could be would be greatly appreciated as I've been stuck at this point for a couple of days.
If you want the root directory of some package(s) to be c:\java\programs\c and the root directory of other package(s) to be c:\java\programs\d, then you have to have those directories in the Classpath - that's how classes are found. This will work but it means adding to your classpath with (nearly) each package.
Or, you could make c:\java\programs the root directory of all packages.
Or, you could use the -classpath option of javac and java so you would only include needed directories.
Or, you could just use the current directory (.) as your classpath.
You can use all or any combination of the above options as well. I use the second and fourth options, but I do not program for a living so my needs are simple.
Similar Messages
-
Cannot resolve symbol, yet another one
Well i've looked into this one more then once... i know the code is good but i still get the error...
Thanks for any help!
D:\java\appletSort.java:62: cannot resolve symbol
symbol : variable i
location: class appletSort
if(data.equals(namn))
^
1 error
Tool completed with exit code 1
//data f�r v�rdet i inruta
String data=inruta.getText();
//rensa utruta
utruta.setText("");
//inruta testas med alla tidigare inskrivna poster
for(int i=0;namn[i]!=null;i++);
//om "data" finns i posten, skriv ut
(62) if(data.equals(namn[i]))
utruta.append(data+"\n");
else
//felmeddelande om s�kningen inte gav n�gra tr�ffar
utruta.setText("S�kningen gav inga tr�ffar");hehe =P oops, thx alot i totally missed that one, well... that happens =P
-
Cannot resolve symbol error when compiling a class that calls another class
I've read all the other messages that include "cannot resolve symbol", but no luck. I've got a small app - 3 classes all in the same package. BlackjackDAO and Player compile OK, but BlackjackServlet throws the "cannot resolve symbol" (please see pertinent code below)...
I've tried lots: ant and javac compiling, upgrading my version of tomcat, upgrading my version of jdk/jre, making sure my servlet.jar is being seen by the compiler (at least as far as I can see from the -verbose feedback)...any help would be GREAT! Thanks in advance...
classes: BlackjackServlet, BlackjackDAO, Player
package: myblackjackpackage
tomcat version: 4.1.1.8
jdk version: j2sdk 1.4.0
ant version: 1.4.1
I get the same error message from Ant and Javac...
C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage>javac *.java -verbose
C:\Tomcat4118\src\webapps\helloblackjack>ant all -verbose
compile error:
BlackjackServlet.java:55: cannot resolve symbol
symbol: method addPlayer (javax.servlet.http.HttpServletRequest,javax.servlet.http.Http
ServletResponse)
location: class myblackjackpackage.BlackjackServlet
addPlayer(request, response);
^
My code is:
package myblackjackpackage;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.lang.*;
/** controller servlet in a web based blackjack game application @author Ethan Harlow */
public class BlackjackServlet extends HttpServlet {
private BlackjackDAO theBlackjackDAO;
public void init() throws ServletException {
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbUrl = "jdbc:microsoft:sqlserver://localhost:1433";
String userid = "testlogin";
String passwrd = "testpass";
try {
theBlackjackDAO = new BlackjackDAO(driver, dbUrl, userid, passwrd);
catch (IOException exc) {
System.err.println(exc.toString());
catch (ClassNotFoundException cnf) {
System.err.println(cnf.toString());
catch (SQLException seq) {
System.err.println(seq.toString());
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String command = request.getParameter("command");
if (command == null || (command.equals("stats"))) {
else if (command.equals("add")) {
try {
//the following line is caught by compiler
addPlayer(request, response);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<p>Hi, your command was " + request.getParameter("command") + "!!!</p>");
out.println("</body>");
out.println("</html>");
catch (Exception exc) {
System.err.println(exc.toString());
else if (command.equals("play")) {
else if (command.equals("bet")) {
else if (command.equals("hit")) {
else if (command.equals("stand")) {
else if (command.equals("split")) {
else if (command.equals("double")) {
else if (command.equals("dealerdecision")) {
else if (command.equals("reinvest")) {
else if (command.equals("changebet")) {
else if (command.equals("deal")) {
package myblackjackpackage;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.lang.*;
public class BlackjackDAO {
private Connection myConn;
public BlackjackDAO(String driver, String dbUrl, String userid, String passwrd)
throws IOException, ClassNotFoundException, SQLException {
System.out.println("Loading driver: " + driver);
Class.forName(driver);
System.out.println("Connection to: " + dbUrl);
myConn = DriverManager.getConnection(dbUrl, userid, passwrd);
System.out.println("Connection successful!");
public void addPlayer(HttpServletRequest request, HttpServletResponse response)
throws IOException, SQLException {
//I've commented out all my code while debugging, so I didn't include
//any here
compiler feedback
C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage>javac *.java -verbose
[parsing started BlackjackDAO.java]
[parsing completed 90ms]
[parsing started BlackjackServlet.java]
[parsing completed 10ms]
[parsing started Player.java]
[parsing completed 10ms]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Object.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/sql/Connection.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/String.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/IOException.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/ClassNotFoundException.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/sql/SQLException.class)]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/http/HttpServletRequ
est.class)]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/http/HttpServletResp
onse.class)]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/http/HttpServlet.cla
ss)]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/GenericServlet.class
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/Servlet.class)]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletConfig.class)
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/Serializable.class)]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletException.cla
ss)]
[checking myblackjackpackage.BlackjackDAO]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Throwable.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Exception.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/System.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/PrintStream.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/FilterOutputStream.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/OutputStream.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Class.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/sql/DriverManager.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/util/Properties.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/Error.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/RuntimeException.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/lang/StringBuffer.class)]
[wrote BlackjackDAO.class]
[checking myblackjackpackage.BlackjackServlet]
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletRequest.class
BlackjackServlet.java:55: cannot resolve symbol
symbol : method addPlayer (javax.servlet.http.HttpServletRequest,javax.servlet
.http.HttpServletResponse)
location: class myblackjackpackage.BlackjackServlet
addPlayer(request, response);
^
[loading c:\tomcat4118\common\lib\servlet.jar(javax/servlet/ServletResponse.clas
s)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/PrintWriter.class)]
[loading c:\j2sdk14003\jre\lib\rt.jar(java/io/Writer.class)]
[checking myblackjackpackage.Player]
[total 580ms]
1 error
C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage>
and here's the ant feedback...
C:\Tomcat4118\src\webapps\helloblackjack>ant all -verbose
Ant version 1.4.1 compiled on October 11 2001
Buildfile: build.xml
Detected Java version: 1.4 in: c:\j2sdk14003\jre
Detected OS: Windows 2000
parsing buildfile C:\Tomcat4118\src\webapps\helloblackjack\build.xml with URI =
file:C:/Tomcat4118/src/webapps/helloblackjack/build.xml
Project base dir set to: C:\Tomcat4118\src\webapps\helloblackjack
Build sequence for target `all' is [clean, prepare, compile, all]
Complete build sequence is [clean, prepare, compile, all, javadoc, deploy, dist]
clean:
[delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build
[delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\images\a_s.g
if
[delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\images\q_s.g
if
[delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\im
ages
[delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\index.html
[delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\newplayer.ht
ml
[delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\clas
ses\myblackjackpackage\BlackjackDAO.class
[delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\WE
B-INF\classes\myblackjackpackage
[delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\WE
B-INF\classes
[delete] Deleting C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\web.
xml
[delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build\WE
B-INF
[delete] Deleting directory C:\Tomcat4118\src\webapps\helloblackjack\build
prepare:
[mkdir] Created dir: C:\Tomcat4118\src\webapps\helloblackjack\build
[copy] images\a_s.gif added as C:\Tomcat4118\src\webapps\helloblackjack\bui
ld\images\a_s.gif doesn't exist.
[copy] images\q_s.gif added as C:\Tomcat4118\src\webapps\helloblackjack\bui
ld\images\q_s.gif doesn't exist.
[copy] index.html added as C:\Tomcat4118\src\webapps\helloblackjack\build\i
ndex.html doesn't exist.
[copy] newplayer.html added as C:\Tomcat4118\src\webapps\helloblackjack\bui
ld\newplayer.html doesn't exist.
[copy] WEB-INF\web.xml added as C:\Tomcat4118\src\webapps\helloblackjack\bu
ild\WEB-INF\web.xml doesn't exist.
[copy] omitted as C:\Tomcat4118\src\webapps\helloblackjack\build is up to
date.
[copy] images added as C:\Tomcat4118\src\webapps\helloblackjack\build\image
s doesn't exist.
[copy] WEB-INF added as C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-
INF doesn't exist.
[copy] Copying 5 files to C:\Tomcat4118\src\webapps\helloblackjack\build
[copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\images\q_s.gif
to C:\Tomcat4118\src\webapps\helloblackjack\build\images\q_s.gif
[copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\images\a_s.gif
to C:\Tomcat4118\src\webapps\helloblackjack\build\images\a_s.gif
[copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\index.html to C
:\Tomcat4118\src\webapps\helloblackjack\build\index.html
[copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\newplayer.html
to C:\Tomcat4118\src\webapps\helloblackjack\build\newplayer.html
[copy] Copying C:\Tomcat4118\src\webapps\helloblackjack\web\WEB-INF\web.xml
to C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\web.xml
compile:
[mkdir] Created dir: C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-INF\
classes
[javac] myblackjackpackage\BlackjackDAO.class skipped - don't know how to ha
ndle it
[javac] myblackjackpackage\BlackjackDAO.java added as C:\Tomcat4118\src\weba
pps\helloblackjack\build\WEB-INF\classes\myblackjackpackage\BlackjackDAO.class d
oesn't exist.
[javac] myblackjackpackage\BlackjackServlet.java added as C:\Tomcat4118\src\
webapps\helloblackjack\build\WEB-INF\classes\myblackjackpackage\BlackjackServlet
.class doesn't exist.
[javac] myblackjackpackage\Player.java added as C:\Tomcat4118\src\webapps\he
lloblackjack\build\WEB-INF\classes\myblackjackpackage\Player.class doesn't exist
[javac] Compiling 3 source files to C:\Tomcat4118\src\webapps\helloblackjack
\build\WEB-INF\classes
[javac] Using modern compiler
[javac] Compilation args: -d C:\Tomcat4118\src\webapps\helloblackjack\build\
WEB-INF\classes -classpath
"C:\Tomcat4118\src\webapps\helloblackjack\build\WEB-I
NF\classes;
C:\tomcat4118\common\classes;
C:\tomcat4118\common\lib\activation.jar;
C:\tomcat4118\common\lib\ant.jar;
C:\tomcat4118\common\lib\commons-collections.jar;
C:\tomcat4118\common\lib\commons-dbcp.jar;
C:\tomcat4118\common\lib\commons-logging-api.jar;
C:\tomcat4118\common\lib\commons-pool.jar;
C:\tomcat4118\common\lib\jasper-compiler.jar;
C:\tomcat4118\common\lib\jasper-runtime.jar;
C:\tomcat4118\common\lib\jdbc2_0-stdext.jar;
C:\tomcat4118\common\lib\jndi.jar;
C:\tomcat4118\common\lib\jta.jar;
C:\tomcat4118\common\lib\mail.jar;
C:\tomcat4118\common\lib\mysql_uncomp.jar;
C:\tomcat4118\common\lib\naming-common.jar;
C:\tomcat4118\common\lib\naming-factory.jar;
C:\tomcat4118\common\lib\naming-resources.jar;
C:\tomcat4118\common\lib\servlet.jar;
C:\tomcat4118\common\lib\tools.jar;
C:\j2sdk14003\lib\tools.jar;
C:\tomcat4118\ant141\lib\servlet.jar;
C:\tomcat4118\ant141\lib\jaxp.jar;
C:\tomcat4118\ant141\lib\crimson.jar;
C:\tomcat4118\ant141\lib\ant.jar;
C:\Tomcat4118\src\webapps\helloblackjack;
C:\mysql\jdbc_dvr\mm.mysql.jdbc-1.2c;
C:\Program Files\SQLserverjdbcdriver\lib\msbase.jar;
C:\Program Files\SQLserverjdbcdriver\lib\msutil.jar;
C:\Program Files\SQLserverjdbcdriver\lib\mssqlserver.jar"
-sourcepath C:\Tomcat4118\src\webapps\helloblackjack\src -g -O
[javac] Files to be compiled:
C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\BlackjackDAO
.java
C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\BlackjackSer
vlet.java
C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\Player.java
[javac] C:\Tomcat4118\src\webapps\helloblackjack\src\myblackjackpackage\Blac
kjackServlet.java:55: cannot resolve symbol
[javac] symbol : method addPlayer (javax.servlet.http.HttpServletRequest,j
avax.servlet.http.HttpServletResponse)
[javac] location: class myblackjackpackage.BlackjackServlet
[javac] addPlayer(request, response);
[javac] ^
[javac] 1 error
BUILD FAILED
C:\Tomcat4118\src\webapps\helloblackjack\build.xml:212: Compile failed, messages
should have been provided.
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:559)
at org.apache.tools.ant.Task.perform(Task.java:217)
at org.apache.tools.ant.Target.execute(Target.java:184)
at org.apache.tools.ant.Target.performTasks(Target.java:202)
at org.apache.tools.ant.Project.executeTarget(Project.java:601)
at org.apache.tools.ant.Project.executeTargets(Project.java:560)
at org.apache.tools.ant.Main.runBuild(Main.java:454)
at org.apache.tools.ant.Main.start(Main.java:153)
at org.apache.tools.ant.Main.main(Main.java:176)
Total time: 1 second
C:\Tomcat4118\src\webapps\helloblackjack>yes!
early on i tried: BlackjackDAO.addPlayer(request, response);
instead of: theBlackjackDAO.addPlayer(request, response);
you rock - thanks a ton -
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. -
HELP PLEASE Cannot resolve symbol error
Only just started to atempt simple java programs and this same error keeps appearing. code i am using is:
import java.io.*;
class Q1
public static void main(String[] args) throws IOException
int num1,num2,sum;
/*program statements start here*/
System.out.printIn ("Input a number");
num1= Course_io.readInt();
System.out.printIn ("Input another number");
num2= Course_io.readInt();
sum= num2 - num1;
System.out.printIn ("Total is" +sum );
and this is the error message i keep getting:
javac -d . -g "C:\Java Programs\Q1.java"
C:\Java Programs\Q1.java:12: cannot resolve symbol
symbol : method printIn (java.lang.String)
location: class java.io.PrintStream
System.out.printIn ("Input a number");
^
C:\Java Programs\Q1.java:16: cannot resolve symbol
symbol : method printIn (java.lang.String)
location: class java.io.PrintStream
System.out.printIn ("Input another number");
^
C:\Java Programs\Q1.java:22: cannot resolve symbol
symbol : method printIn (java.lang.String)
location: class java.io.PrintStream
System.out.printIn ("Total is" +sum );
^
3 errors
Please help me, Thankyou.sum= num2 - num1;
System.out.printIn ("Total is" +sum );While you're at it, do something about this, it's misleading.
kind regards,
Jos -
Compiler error cannot resolve symbol
Hi people,
i'm having this compile time error that, when i create a class and calling that class in another class gives the error cannot resolve symbol classname and it also happened when i created a bean and referencing the bean class in another bean when i'm using Jsp. thanks in advance.It would be helpful if you post the exact error message. If you use a system Classpath, then it must contain the root directory for the package directory(s).
For example, if the source code for a file starts with
package my.package;
and you have a directory structure c:\myjava\classes\my\package then the Classpath must contain c:\myjava\classes. -
Cannot resolve symbol - getCodeBase()
Hey,
I'm trying to read from a file into my java applet however, I get the following error:
Player.java [49:1] cannot resolve symbol
symbol : method getCodeBase ()
location: class Player
url = new URL(getCodeBase().toString() + "/bot" + playerNo + ".txt");
^
1 error
Errors compiling Player.
The ^ should point at the 'g' of getCodeBase. I'm not sure what is up as I import both .net.* and .applet.* and have used similar syntax in another class which works fine. Any ideas what's up?getCodeBase() is an Applet method. You need you have a reference to the applet.,
-
Import javax.ejb.EJBHome; cannot resolve symbol
Hi i wonder if anyone can help me. I have read alot of the posts regarding this issue and have tried everything to do with the paths and environmental variables and even reinstalled everything.
import javax.ejb.EJBHome; cannot resolve symbol
This is the problem i keep getting and here are the paths that i set:
SET PATH=c:\j2sdkee1.3\bin;c:\jdk1.3.1_01\bin;c:\jakarta-ant-1.3\bin
SET ANT_HOME=c:\jakarta-ant-1.3
SET JAVA_HOME=c:\jdk1.3.1_01
SET J2EE_HOME=c:\j2sdkee1.3
SET CLASSPATH=c:\j2sdkee1.3\lib\j2ee.jar;c:\jakarta-ant-1.3\lib\ant.jar;c:\jdk1.3.1_01\lib\tools.jar
What am i doing wrong???Im not sure, everything looks ok to me, but here is what i tried:
I wrote this little test class, and compiled it
import javax.ejb.EJBHome;
public class test
public test()
I got the same error you did (or similar)
D:\>javac test.java
test.java:1: package javax.ejb does not exist
import javax.ejb.EJBHome;
^
1 error
then I added the j2ee.jar to my classpath and everything worked fine.
here are my env vars:
JAVA_HOME=d:\dev\jdk
J2EE_HOME=d:\dev\j2sdkee
CLASSPATH=...;%J2EE_HOME%\lib\j2ee.jar
If I were you I would double check all the paths you have set up then try a simple case like the one above. If your running NT/2000 make sure the JAVA_HOME, J2EE_HOME and CLASSPATH are system variables not user variables. Another thing you can try is adding the j2ee.jar to the classpath with the -classpath compiler switch.
javac -classpath %CLASSPATH%;d:\dev\j2sdkee\lib\j2ee.jar test.java
Other than those things I'm not sure
Good Luck -
JSP Compilation Problem - Cannot Resolve Symbol
I cannot see the problem. Maybe I am not sober at 2:30 am.
<%
Collection postBeans = ( Collection )request.getAttribute( "PostBeans" );
Iterator iterator = postBeans.iterator();
int i = 0;
while( iterator.hasNext() )
PostBean postBean = (PostBean)iterator.next();
i++;
String background;
if ( postBean.getParentPostID() == 0 )
background = "#FFCE9C";
else
if ( ( i%2 ) != 0 )
background = "#EEEEEE";
else
background = "#FFFFFF";
%>
<table width="95%" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#999999">
<tr bgColor=<%=background%>>
</tr>
</table>I got compilation error: cannot resolve symbol
symbol: backgroundI put the variable 'background' outside the while loop. The 'cannot resolve symbol' problem is gone. But, I got another compilation error:
>
unexpected type
required: variable
found : value
out.write("\r\n }\r\n i++;\r\n if ( postBean.getParentPostID() == 0 ) \r\n {\r\n background = \"#FFCE9C\";\r\n }\r\n else \r\n {\r\n if ((i%2) != 0) \r\n {\r\n background = \"#EEEEEE\";\r\n } \r\n else \r\n {\r\n background = \"#FFFFFF\";\r\n }\r\n }\r\n%>\r\n");
The code looks like:
<%
String background;
Collection postBeans = ( Collection )request.getAttribute( "PostBeans" );
Iterator iterator = postBeans.iterator();
int i = 0;
while( iterator.hasNext() )
PostBean postBean = (PostBean)iterator.next();
i++;
if ( postBean.getParentPostID() == 0 )
background = "#FFCE9C";
else
if ( ( i%2 ) != 0 )
background = "#EEEEEE";
else
background = "#FFFFFF";
%>
<table width="95%" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#999999">
<tr bgColor=<%=background%>>
</tr>
</table> -
Cannot Resolve Symbol Frustrations
Here is the code:
private void populateTabbedPane()
tabbedPane.addTab("Welcome", null, new HTBegin(),
"Welcome to Hot Tub");
tabbedPane.addTab("Start", null, new HTStartup(),
"Start up Tub");
Here is the error:
C:\Java\Steve>javac -d . Hottub.java
Hottub.java:44: cannot resolve symbol
symbol : method addTab (java.lang.String,<null>,hottub.HTStartup,java.lang.String)
location: class javax.swing.JTabbedPane
tabbedPane.addTab("Start", null, new HTStartup(),
...............^
1 error
Notice it is on the second addTab and NOT the first. HTBegin and HTStartup classes exist and are found when the -verbose is added to the compile. Yet this error occurs on all of the addTab functions below the first.
As an addition, If I comment out the first addTab line and just run with the second line, the same error occurs. I have deleted and re-typed the line many times.
I'm just learning this language but this seems nuts!
My path is PATH=C:\BITWARE\;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\READIBMW;C:\JAVA\STEVE;C:\JAVA\BIN
Any suggestions?I think I have solved the issue with the following. As requested, HTStartup is displayed as it was when I originally posted the question. There is not much to it so I figured that wasn't the issue. Especially when the error appears to be the addTab statement from the main line class.
package hottub;
import javax.swing.*;
import java.awt.*;
public class HTStartup
{ // Open Class
} // Close Class
This is what I changed it to:
package hottub;
import javax.swing.*;
import java.awt.*;
public class HTStartup extends JPanel
{ // Open Class
} // Close Class
The compile is clean with the addition of extends JPanel. The mainline class compiles.
Thanks for the help! -
When i try to use max() & pow() in jdbc i get error "cannot resolve symbol"
hi,
when i tried to use pow() & max() in my jdbc programme i got compilation error "cannot resolve symbol".
even i have imorted java.math
this is the sample.
pr1= (fy/(L*B*pow(10.0,-6.0))+((6*mx)/(L*B*B*pow(10.0,-6.0)))+((6*mz)/(B*L*L*pow(10.0,-6.0))));
all of above are double.
and with max();
pr=max(pr1,pr2);
all of above are double.
please help.
thanks in advance.
satishhi
Hartmut
thanks hartmut;
i am new in java so i have some problems, but thanks for helping me.
please help me again.
as i have already posted another probleme which i have with selecting 1000 rows 1 by 1 from a table & manipulate 1 by 1 on that and then store all manipulated row to another table.
when i tried to do so i am able to select only 600 rows and manipulate them & store them.
i did not get any exception or any error.
can this possible that microsoft access driver has not that much capacity to provide 1000 rows or it is problem with jdbc.
please help.
satish
thanks again. -
"cannot resolve symbol" when compiling a class that calls methods
I am currently taking a Intro to Java class. This problem has my instructor baffled. If I have two classes saved in separate files, for example:
one class might contain the constructor with get and set statements,
the other class contains the main() method and calls the constructor.
The first file compiles clean. When I compile the second file, I get the "cannot resolve symbol error" referring to the first class.
If I copy both files to floppy and take them to school. I can compile and run them with no problem.
If I copy the constructor file to the second file and delete the "public" from the class declaration of the constructor, it will compile and run at home.
At home, I am running Windows ME. At school, Windows 2000 Professional.
The textbook that we are using came with a CD from which I downloaded the SDK and Runtime Environment. I have tried uninstalling and reinstalling. I have also tried downloading directly from the Sun website and still the error persists.
I came across a new twist tonight. I copied class files from the CD to my hard drive. 4 separate files. 3 of which are called by the 4th.
I can run these with no problem.
Any ideas, why I would have compile errors????
Thanks!!Oooops ... violated....
Well first a constructor should have the same name as the class name so in our case what we have actually created is a static method statementOfPhilosophy() in class SetUpSite and not a constructor.
Now why does second class report unresolved symbol ???
Look at this line
Class XYZ=new XYZ();
sounds familiar, well this is what is missing from your second class, since there is no object how can it call a method ...
why the precompiled classes run is cuz they contain the right code perhaps so my suggestion to you is,
1) Review the meaning and implementation of Constructors
2) Ask your instructor to do the same ( no pun intended ... )
3) Check out this for understanding PATH & CLASSPATH http://www.geocities.com/gaurav007_2000/java/
4) Look at the "import" statement, when we have code in different files and we need to incorporate some code in another it is always a good idea to use import statement, that solves quite a few errors.
5) Finally forgive any goof up on this reply, I have looked at source code after 12 months of hibernation post dot com doom ... so m a bit rusty... shall get better soon though :)
warm regards and good wishes,
Gaurav
CW :-> Mother of all computer languages.
I HAM ( Radio-Active )
* OS has no significance in this error
** uninstalling and reinstalling ? r u nuttttttts ??? don't ever do that again unless your compiler fails to start, as long as it is giving a valid error it is working man ... all we need to do is to interpret the error and try to fix the code not the machine or compiler. -
"cannot resolve symbol" error when using super.paintComponent
I am trying to override the paintComponent method in a class extending a JFrame, but when I call super.paintComponent(g) from inside the overridden method I get the error
QubicGUI.java:63: cannot resolve symbol
symbol : method paintComponent (java.awt.Graphics)
location: class javax.swing.JFrame
super.paintComponent(g);
^
1 error
I can't see where I am deviating from examples I know work. It is a very small program, so I have included it here:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.net.URL;
class QubicGUI extends JFrame
private int width;
private int height;
private Image background;
public int getWidth()
{ return width; }
public int getHeight()
{ return height; }
public boolean isOpaque()
return true;
public QubicGUI()
super("Qubic"); //set title
// The following gets the default screen device for the purpose of finding the
// current settings of height and width of the screen
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = environment.getDefaultScreenDevice();
DisplayMode display = device.getDisplayMode();
width = display.getWidth();
height = display.getHeight();
// Here we set the window to cover the entire screen with a black background, and
// remove the decorations. (This includes the title bar and close, minimize and
// maximize buttons and the border)
setUndecorated(false);
setVisible(true);
setSize(width,height);
setResizable(false);
setBackground(Color.black);
// Initializes the background Image
Image background = Toolkit.getDefaultToolkit().getImage("background.gif");
// This is included for debugging with a decorated window.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} // end constructor
public void paintComponent(Graphics g)
super.paintComponent(g);
} // end paintComponenet
} // end QubicGUITwo things I want to know:
1. I was trying to access a variable as JLabel
myLabel; defined in the constructor of a class from
the constructor of another class. I got this error
message - "Cannot access non-static variable from a
static context". Why(When both are non-static am I
getting the message as static context)?Post some code. It's hard to pinpoint a syntax error like that without seeing the code.
Also, there may be cleaner ways of doing what you want without having classes sharing labels.
2. I am using a map to set the attributes of a font.
One of the key-value pair of the map is
TextAttributesHashMap.put(TextAttribute.FOREGROUND,Colo
.BLUE);
But when I using the statement g.drawString("First
line of the address", 40, 200); the text being
displayed is in black and not blue. Why?You need to use the drawString that takes an AttributedCharacterIterator:
import java.awt.*;
import java.awt.font.*;
import java.text.*;
import javax.swing.*;
public class Example extends JPanel {
public static void main(String[] args) {
JFrame f = new JFrame("Example");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = f.getContentPane();
cp.add(new Example());
f.setSize(400,300);
f.setLocationRelativeTo(null);
f.setVisible(true);
protected void paintComponent(Graphics g) {
super.paintComponent(g);
String text = "Every good boy does fine always";
AttributedString as = new AttributedString(text);
as.addAttribute(TextAttribute.FAMILY, "Lucida Bright");
as.addAttribute(TextAttribute.SIZE, new Float(16));
as.addAttribute(TextAttribute.FOREGROUND, Color.BLUE, 0, 5);
as.addAttribute(TextAttribute.FOREGROUND, Color.GREEN, 6, 10);
as.addAttribute(TextAttribute.FOREGROUND, Color.RED, 11, 14);
as.addAttribute(TextAttribute.FOREGROUND, Color.YELLOW, 15, 19);
as.addAttribute(TextAttribute.FOREGROUND, Color.MAGENTA, 20, 24);
as.addAttribute(TextAttribute.FOREGROUND, Color.CYAN, 25, 31);
g.drawString(as.getIterator(), 10, 20); -
Cannot resolve symbol..Swing / MDI
I'm somewhat new to Java.
I have an MDI app that I am creating. The main routine is in DeskTop.java.
When DeskTop.class is run:
1)Main creates a generic UserID class from userID.java( has two private strings and 4 methods to get userid, passwd, and set userid, passwd).
This info will be used throughout the app to connect to various MySQL Dbs.
2)Main creates the main application JFrame and a JMenu.
One of the JMenuItems, named Logon creates a JInternalFrame (basically a login box with userid and password field and JButton called continue. An ActionPerformed is added to a continue JButton.
There are many other JInternalFrames on the menu that have various DB functions.
I need to have the action performed on the ActionEvent of the continue button access the UserID class and it's setUserID() and setPasswd() methods and set the (uid, pw) fields in the object. Yet anytime I try to access this object from the Logon object, I get a Cannot resolve symbol:
This is a summary of the action performed on the continue button:
uid = txt_userID.getText();
userid = new String(uid).trim();
pw = pw_password.getPassword();
password = new String(pw).trim();
UserID.setUserID(userid); /*UserID is the other object.Error is on*/
UserID.setPasswd(password); /*the decimal point.*/
All objects have a public constructor and the methods I am trying access are declared public.
Files consist of (all in same directory):
DeskTop.java (main JFRAME)
PasswordBox.java ( JInternalFrame)
UserIDPW.java (JInternalFrame)
AddCompany.java (JInternalFrame)
etc. ( other JInternalFrames)
etc. ( other classes)
Thanks for any input. If someone has a better method of making a MDI database app in Java, some info would be great.
There will be other classes outside the gui. I am trying to build the business logic and the gui as seperate as I can.This may sound silly to ask, but without seeing all
the code in this case you can imagine it's difficult
to say - I presume that UserID is a class (ie a
template for an object) rather than an object itself
and that setUserID, setPasswd are static functions.
The files you list dont include a UserID.java, so this
means you haven't got a PUBLIC class called UserID
(you may have one with private or package / friendly
access) - hence you can't access it from outside. I am
new myself - but this looks a likely candidate. [ I
try to answer questions so that I can learn myself,
but now I am off to bed!]Thank for the reply.
The main function creates a public UserID object and it created the main gui JFrame DeskTop object. UserID has a public constructor and public methods.
main function:
public static void main(String args[]) {
userIDPW userID = new userIDPassword();
JFrame f = new DeskTop();
Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(screensize);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
The DeskTop object has a JMenuitem in it called Login, it opens an InternalJFrame called PasswordBox.
PasswordBox takes a userid and pw and then it needs to send the userid and pw to the userID object with two of its methods:
Methods in userID object:
public void setUserID(String userid)
{ this.userid = userid; }
public void setPasswd(String passwd)
( this.passwd = passwd; }
How doed one access this object (userID)? I have tried (from the PasswordBox) with no success:
uid = txt_userID.getText();
userid = new String(uid).trim();
pw = pw_password.getPassword();
password = new String(pw).trim();
userID.setUserID(userid); --this fails, with Cannot resolve symbol
userID.setPasswd(password); --this fails, with Cannot resolve symbol -
Hi everyone!
I'm trying to get started with J2ME programming, which is actually going great so far, except that I've hit a wall.
I need to use floating point numbers, which aren't supported when using MIDP, so I'm trying to use an addon, namely henson.midp (http://henson.newmail.ru/j2me/Float.htm).
I've saved the .java file to the correct directory, and it is of course being compiled along with the other files, however, I can only create .Float variables and not access functions, it seems.
henson.midp.Float f; // OK
f = henson.midp.Float(1234); // cannot resolve symbol error, arrow pointing at the dot between 'henson' and 'midp'
I suppose I'm doing something wrong, but what? :)
Help would be greatly appreciated.
/Confused java newbieMore trouble on the way, it seems!
Because of some trouble I'm having with the henson class, I figured I'd try another one, so I downloaded 'Real' (http://gridbug.ods.org/Real.html) again, and tried a simple
Real a = new Real("0.5");... as used in the sample, and also by myself yesterday.
Well guess what, more cannot resolve symbol trouble.
C:\...\src\CurrEx.java:123: cannot resolve symbol
symbol : class Real
location: class CurrEx
Real a = new Real("0.5");
^
C:\...\src\CurrEx.java:123: cannot resolve symbol
symbol : class Real
location: class CurrEx
Real a = new Real("0.5");
^
2 errors
com.sun.kvem.ktools.ExecutionException
Build failedAgain, the source file is in the correct directory and it is getting compiled along with the rest, and I'm pretty sure that at least the code (1 line) is correct this time.
Maybe you are looking for
-
I have a PC (not Mac/apple computer) with dual monitors.
I have a problem with itune in full screen blacking out my second monitor. How do I fix this problem?
-
OFFLINE backup and DB13 jobs configuratins error in MSCS cluster with OFS
Hello, We have recently installed SAP ERP 6.0 EhP4 SR1 in MSCS cluster using Oracle Fail Safe. The installation is successful and all the failover scenarios work fine. I need to schedule offline backups and DB13 jobs, which is not possible in current
-
Did the markup for java applets change with version 4.0.5
Starting with Safari version 4.0.5 java applets are not rendering correctly. The Java coffee cup loading image pushes the actual content down. Was the applet tag markup changed with this release? Take a look at the following example: http://tinyurl.c
-
I am running a Java 1.4+ application on a Mac OS X 10.4.10 Intel. If I change the locale of the system to English, French or German, and I start my application, I can see the Application Menu translated properly. (I am referring to About/Preferences/
-
Can't open a document or run on Windows 8.1
Any ideas why I can't open a document or open the program on Windows 8.1?