Error when compiling cannot resolve symbol
I am kind of new to java please take a look into this code. I am getting this error cannot resolve the symbol.
this is the first class I saved under folder called javapractice as t1. I don't get any error message when I compile this, but when I compile the second class I got the error message.It would be appreciated if someone can help. thanks
package javapractice;
public class t1{
double a;
double b;
double c;
t1(double ax){
a = ax;
b = 0;
c = 0;
this is the second class also I saved as t2 under javapractice folder. when I compile this class I got the error cannot resolve the name.
package javapractice;
public class t2 {
public static void main(String args[]) {
t1 d = new t1();
d.a = 3;
System.out.println(d.a);
System.out.println(d.b);
System.out.println(d.c);
The problem ist1 d = new t1();You need to pass a double param. to the constructor of t1t1 d = new t1((double)10.0);
Similar Messages
-
Error when activating - "cannot resolve symbol"
Hi everybody!
I created a WebDynpro DC referencing some other DC's, one of them containing some generated Enterprise Connector classes.
A local build works fine, the WebDynpro looks and works as expected when deployed to our J2EE server. When I activate the associated activities, all DC except the WebDynpro DC compile o.k., but the WebDynpro compilation throws some "cannot resolve symbol" errors, the symbols being the generated classes from the Enterprise Connector DC.
The Activation Log of this component shows that only one class of this DC is being compiled and packed into the public parts of the DC:
[echo] Starting Java compiler
[javac] Compiling 1 source file to /usr/sap/...somewhere.../classes
[timer] Java compilation finished in 0.375 seconds
[echo] Start XLF conversion
[timer] XLF conversion finished in 0.001 seconds
createPublicParts:
[pppacker] Packing assembly public part 'mvRFCAss'
[pppacker] Packed 0 files for entity mvRFCObjects.util (Java Package/Class, mvRFCObjects/util)
[pppacker] Packed 2 files for entity mvRFCObjects (Java Package/Class, mvRFCObjects)
[pppacker] Packed 2 entities for assembly public part 'mvRFCAss'
[timer] Packing of assembly public part 'mvRFCAss' finished in 0.059 seconds
[pppacker] Packing compilation public part 'mvRFCComp'
[pppacker] Packed 0 files for entity GeschaeftsPartnerRFC_PortType (Java Class/Class, mvRFCObjects)
[pppacker] Packed 0 files for entity Z_Ecm_Input (Java Class/Class, mvRFCObjects)
[pppacker] Packed 0 files for entity Z_Ecm_Output (Java Class/Class, mvRFCObjects)
[pppacker] Packed 0 files for entity Ztgd_EcmType (Java Class/Class, mvRFCObjects)
[pppacker] Packed 0 files for entity Ztgd_EcmType_List (Java Class/Class, mvRFCObjects/util)
[pppacker] Packed 2 files for entity MVTestSapAccess (Java Class/Class, mvRFCObjects)
[pppacker] Packed 6 entities for compilation public part 'mvRFCComp'
[timer] Packing of compilation public part 'mvRFCComp' finished in 0.095 seconds
Any hint on what produces such an error or what information you'd need so say something ?
Thanks!After messing around a bit, we finally deleted both assembly and compilation public parts of all the referenced DC's, created new ones and reestablished the references exactly as defined previously, and now it works properly. Strange thing, though...
-
Java Bean Error in JSP: Cannot Resolve Symbol FirstBean
I have created a java bean with following package statement
package mybeans;
and my bean name is
FirstBean
it compile secessfully and now my directory structure is following
WebAppRootDir \ WEB-INF \ classes \ mybeans \ FirstBean.class
I am using Tomcat 4.1 and in JSP i am declaring the bean with following line
<jsp:useBean id="b" class="mybeans.FirstBean" />
and tomcat 4.1 is failed to find this bean and giving me following error
cannot resolve symbol
symbol : class StudentBean
location: package mybeans
mybeans.FirstBean b = null;
all my class and directory structure is ok i am puzzle why this error is coming, plz help me quickly i need solution quickly ...Error is for StudentBean, not for FirstBean. So check for it.
-
Java Bean Error in JSP: Cannot Resolve Symbol Error
I have created a java bean with following package statement
package mybeans;
and my bean name is
FirstBean
it compile secessfully and now my directory structure is following
WebAppRootDir \ WEB-INF \ classes \ mybeans \ FirstBean.class
I am using Tomcat 4.1 and in JSP i am declaring the bean with following line
<jsp:useBean id="b" class="mybeans.FirstBean" />
and tomcat 4.1 is failed to find this bean and giving me following error
cannot resolve symbol
symbol : class FirstBean
location: package mybeans
mybeans.FirstBean b = null;
all my class and directory structure is ok i am puzzle why this error is coming, plz help me quickly i need solution quickly ...It seem to be ok... why dont your try with a newer versi�n of Tomcat?
-
IntValue - ")" expected and Cannot Resolve Symbol
I used intValue to convert an Integer to primitive (see below) and ran into syntax errors.
LogDataBean lb = new LogDataBean();
lb.setLog_time( ( String )row.get( "LOG_TIME" ) );
lb.setLog_pid( intValue( Integer )row.get( "LOG_PID" )); //where syntax error occur
lb.setLog_user( ( String )row.get( "LOG_USER" ) );the row.get( "LOG_PID" ) gets the value of the column "LOG_PID" from a database table and returns an object. Therefore, I first cast the object to Integer and then try to use the intValue to convert it to a primitive int.
But, the statement resulted in compilation error: ")" expected.
When I modified the statement a little bit by adding a pair of parenthesis:
lb.setLog_pid( intValue( ( Integer )row.get( "LOG_PID" ) ) ); //where syntax error occurI got "Cannot Resolve Symbol: intValue". I have import java.lang.Integer in the beginning of the class.Integer.parseInt(row.get( "LOG_PID" ))
I'm assuming thats what you want to. Although you syntax is terribly wrong. Have a look at some tutorials. -
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. -
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 -
Compiling error - cannot resolve symbol
Hi,
I am working on writing out this basic code for a project. When I compile, I get an error "Cannot resolve symbol" for the gpa variable. Please help!
My intention is to use the hours and points from the crHours and nbrPoints methods, and use them to calculate GPA in the grPtAvg method:
public class Student
public static void main(String[]args)
idNum();
crHours();
nbrpoints();
gpa = grPtAvg(hours, points);
System.out.println("Student's GPA is " + gpa);
public static void idNum()
int id = 2520;
System.out.println("Student's ID is " + id);
public static float crHours()
float hours = 5;
System.out.println("Student's credit hours are " + hours);
return hours;
public static float nbrpoints()
float points = 22;
System.out.println("Student's earned points are " + points);
return points;
public static float grPtAvg(float hours, float points)
float gpa;
gpa = points / hours;
System.out.println("Student's computed GPA is " + gpa);
return gpa;That's because you're doing the same thing (in a somewhat different way) with those.
The variables: hours and points have already been returned to main methd, right?Yes, but then the main method ignores them.
So, they should be available at this point in the code, is that right?Available in the sense that you can read them, but not in the sense that there are hours and points variables within scope in the main method.
You want to do this:
public static void main(String[] args) {
idNum();
float hours = crHours();
float points = nbrpoints();
//create a new float
float myComputetdGpa = grPtAvg(hours, points);
System.out.println("Student's GPA is " + myComputedGpa);
} -
Javac compiler Error - cannot resolve symbol - symbol StringBuilder?
Hi ,
I am using hp - ux system with java version "1.4.2.06". when i try to compile a program called CharSequenceDemo.java which is found in the java tutorials at this link
[CharSequenceDemo.java|http://java.sun.com/docs/books/tutorial/java/IandI/examples/CharSequenceDemo.java]
i get the following error:
$/opt/java1.4/bin/javac CharSequenceDemo.java
CharSequenceDemo.java:38: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
StringBuilder sub =
^
CharSequenceDemo.java:39: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
new StringBuilder(s.subSequence(fromEnd(end), fromEnd(start)));
^
CharSequenceDemo.java:44: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
StringBuilder s = new StringBuilder(this.s);
^
CharSequenceDemo.java:44: cannot resolve symbol
symbol : class StringBuilder
location: class CharSequenceDemo
StringBuilder s = new StringBuilder(this.s);
^
4 errors
Please help on how to compile this program.I've been struggling with the same issue. The difference is that my system says I'm using version 1.6.0_05. I've tried running jucheck.exe. It tells me I've got the latest version installed.
Here is the code:
import java.lang.StringBuilder;
import java.util.Formatter;
public class UsingFormatter {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("usage: " +
"java format/UsingFormatter <format string>");
System.exit(0);
String format = args[0];
StringBuilder stringBuilder = new StringBuilder();
Formatter formatter = new Formatter(stringBuilder);
formatter.format("Pi is approximately " + format +
", and e is about " + format, Math.PI, Math.E);
System.out.println(stringBuilder);
}When I type javac UsingFormatter.java, I get:
UsingFormatter.java:1: cannot resolve symbol
symbol : class StringBuilder
location: package lang
import java.lang.StringBuilder;
^
UsingFormatter.java:2: cannot resolve symbol
symbol : class Formatter
location: package util
import java.util.Formatter;
^
UsingFormatter.java:14: cannot resolve symbol
symbol : class StringBuilder
location: class UsingFormatter
StringBuilder stringBuilder = new StringBuilder();
^
UsingFormatter.java:14: cannot resolve symbol
symbol : class StringBuilder
location: class UsingFormatter
StringBuilder stringBuilder = new StringBuilder();
^
UsingFormatter.java:15: cannot resolve symbol
symbol : class Formatter
location: class UsingFormatter
Formatter formatter = new Formatter(stringBuilder);
^
UsingFormatter.java:15: cannot resolve symbol
symbol : class Formatter
location: class UsingFormatter
Formatter formatter = new Formatter(stringBuilder);
^
6 errors
The compiler refuses to recognize the symbols StringBuilder and Formatter.
I have spent hours googling for an answer and trying every suggestion. Nothing works, not even the one about dropping the computer from the rooftop.
Ultimately, what I'm trying to accomplish (in a different program) is to use a text file as a form letter template and replace the %s placeholders with stings from my form object.
Any advice?
Edited by: javastudent_99 on Apr 3, 2008 1:48 PM -
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. -
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 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. -
Compile error - cannot resolve symbol
Hello,
I am trying this code although I get compile errors as stated.
import java.util.Scanner;
* Write a program that reads 10 numbers from the keyboard into
* an array and then prints the list of numbers
* Modify the above program so that it prints the numbers in reverse order
class Keyboard
public static void main (String[] argStrings)
System.out.println("Enter 10 numbers please");
Scanner scan = new Scanner(System.in);
int[] newArray = new int[10];
for(int i = 0; i < 10; i++)
newArray[i] = scan.nextInt();
System.out.println();
for(int i = 9; i > 0; i--)
System.out.print(newArray);
System.out.println();
I have googled for solutions but have had no luck or could not understand.
Please could someone explain what is going on.
CheersE:\Documents and Settings\John\Desktop\Computing\Programming\Weeks\Week11\Keyboard.java:1: cannot resolve symbol
symbol : class Scanner
location: package util
import java.util.Scanner;
^
E:\Documents and Settings\John\Desktop\Computing\Programming\Weeks\Week11\Keyboard.java:15: cannot resolve symbol
symbol : class Scanner
location: class Keyboard
Scanner scan = new Scanner(System.in);
^
E:\Documents and Settings\John\Desktop\Computing\Programming\Weeks\Week11\Keyboard.java:15: cannot resolve symbol
symbol : class Scanner
location: class Keyboard
Scanner scan = new Scanner(System.in);
^
3 errors
Tool completed with exit code 1
cheers -
Error compiling EJB.jar + cannot resolve symbol+while deploying
I am getting following
Error compiling EJB.jar , cannot resolve symbol ,Syntax error in source, am getting around 17 errors while deploying EAR generated using Jdev905 into standalone oc4jContainers(10g).
Can anyone please help me out where is the problem.
Regards,
Anupcannot resolve symbol ,Syntax error in source
indicates some jar file is not in the Classpath. Is j2ee.jar in the Classpath?
Maybe you are looking for
-
How to trigger sender rfc from r3 system
Hi experts, can any body send documents about " how to trigger sender rfc from r3 system" regards sandeep.
-
What if the '5 r's" don't work?
My Ipod is frozen on the "DND" screen. I've tried all five R's to no avail. A friend suggested running the battery out but the darn thing is fully charged and it could literally be days before the thing dies! Any other suggestions? Thanks in advance!
-
PSE 10 crashes every time I try to use it.
I downloaded and installed PSE 10 on my new Windows 7 64 bit machine about a week ago. PSE 10 ran amazingly fast until yesterday. I have imported and tagged several thousand images. Last night Organizer slowed down dramatically. Today, every time I
-
How do I create 1/4 page flyers on the Mac?
When I select "print 4 to a page" on my printer- it just prints my text in the top left quadrant and leaves the rest blank. I'm using word for mac- and it is really tough to literally create the flyer four times on the same page (my text boxes will
-
I'm using JDeveloper Beta 2.0 and going through the tutorials. Everything runs fine within JDeveloper, however, I get no data and the following error when deploying an applet: borland.jbcl.dataset.DataSetException: The driver: oracle.jdbc.driver.Orac