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.
Similar Messages
-
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?
-
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...
-
JSP cannot resolve symbol symbol: constructor ItemList
I get the following compilation error.
cannot resoolve symbol
symbol :constructor ItemList (java.sql.Connection,java.lang.String)
location: class ItemList
ItemList lst = new ItemList(conn."select * from Items ... );
-------I have the ItemList.java and .class files in the WEB-INF/classes directory. I am using Forte 4.0 CE.
-------My Code-----
<%@page contentType="text/html"%>
<%@page import="java.sql.*" %>
<--dbaccessItems.jsp-->
<html>
<head>
<title>Query Database</title>
</head>
<body>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:Lecture5", "", "");
String max_price = request.getParameter("max_price");
ItemList lst = new ItemList(conn, "select * from Items where price < " + max_price + " ");
for (int i=0; i < lst.getItemCount(); i++)
Item itm = lst.getItem(i);
%>
<%= itm.getName() %>
<BR>
<TABLE Border=1>
<TR>
<TH>ID </TH>
<TH>Product Name</TH>
<TH>Quantity </TH>
<TH>Price </TH>
</TR>
<TR>
<TD> <% itm.getId(); %> </TD>
<TD> <% itm.getName(); %> </TD>
<TD> <% itm.getPrice(); %> </TD>
<TD> <% itm.getQty(); %> </TD>
</TR>
</TABLE>
<%
%>
<!--
0. Use pricesearch.html to enter "max price" if the item
1. Modify this JSP so it uses "max price" passed from pricesearch.html,
queries records from the database where price < "max price"
2. Displays item's id, name, price and qty formatted in the <TABLE>
-->
</body>
</html>tt
-
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);
-
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. -
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. -
JSP page "cannot resolve symbol"
Hi,
I'm using j2sdk1.4.2_01 and tomcat-5.0.13. I'm developing within Eclipse 3.0.0 with the Tomcat plugin.
In my project ("Agenda2") i only created one class ("Persona"), that is correctely compiled (%TOMCAT_HOME%\webapps\Agenda2\WEB-INF\src\Persona.java results in %TOMCAT_HOME%\webapps\Agenda2\WEB-INF\classes\Persona.class, and 0 problems are shown in the Problems list.
In %TOMCAT_HOME%\webapps\Agenda2 i have my Edit.jsp, that begins with these lines:
<%@ page language="java" contentType="text/html" %>
<HTML>
<HEAD>
<TITLE>Edit</TITLE>
</HEAD>
<BODY>
<jsp:useBean id="personaAtt" class="Persona">
<jsp:setProperty name="personaAtt" property="*" />
</jsp:useBean>
....When i call the JSP from the browser, i get this error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 8 in the jsp file: /Edit.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Programmi\Java\tomcat-5.0.13\webapps\Agenda2\work\org\apache\jsp\Edit_jsp.java:48: cannot resolve symbol
symbol : class Persona
location: class org.apache.jsp.Edit_jsp
Persona personaAtt = null;
^The error message mentions line 8, which is the one following <BODY>, that is
<jsp:useBean id="personaAtt" class="Persona">My impression is that there is some path problem, but despite my tries i can't get it.
The folders tree under %TOMCAT_HOME%\webapps\Agenda2\ is:
-WEB-INF
--classes
--lib
--src
-work
--org
---apache
----jspDoes anybody can see the problem ?Thanks! I'm going to try to put the class into a package as both you have suggested, and i'll post here the result.
In the meantime i have a related newbie question:
putting the class into a package, is this kind of a workaround, or it's the "normal thing" ?
I mean, is it mandatory to put classes into a package in order to import them from JSP pages ?
It was my understanding that it isn't mandatory, but - from your replies and many other posts in this forum - i'm starting to think that i'm wrong. -
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. -
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 -
Cannot resolve symbol error even with class imported
Hi
I'm trying to print out a java.version system property but keep getting a
cannot resolve symbol error
symbol: class getProperty
location: class java.lang.System
I've looked at the API and getProperty() is a method of lang.System
Can anyone throw any light?
thanks
import java.lang.System;
class PropertiesTest {
public static void main(String[] args) {
String v = new System.getProperty("java.version");
System.out.println(v);
}Thanks Jos
It compiles but I now get a runtime error
Exception in thread "main"
java.lang.NoClassDefFoundError:PropertiesTest
What do you reckon is the problem?
thanks
java -cp .;<any other directories or jars>
YourClassNameYou get a NoClassDefFoundError message because the
JVM (Java Virtual Machine) can't find your class. The
way to remedy this is to ensure that your class is
included in the classpath. The example assumes that
you are in the same directory as the class you're
trying to run.I know it's a bad habit but I've put this file (PropertiesTest.java) and the compiled class (PropertiesTest.class) both in my bin folder which contains the javac compiler -
Cannot resolve symbol : class odbc ERROR
Hi Helper
I am trying to compile a the following and I am getting the error
C:\jdk\websiter>javac MainServlet.java
MainServlet.java:86: cannot resolve symbol
symbol : class odbc
location: package jdbc
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
import java.util.*;
* This is the servlet to send the user the names of all the sites present in the database
public class MainServlet extends HttpServlet implements ServletConstants
Connection m_con;
PreparedStatement m_pstmt;
ResultSet m_res;
Vector m_vecsiteName;
public void Init(ServletConfig config) throws ServletException {
super.init(config);
}// end of init()
public void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
m_vecsiteName = new Vector();
try {
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
m_con = DriverManager.getConnection("jdbc:odbc:sitewd", "", "");
How can i fix it? thanks
VTReplace the Statement
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
as
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); -
Cannot resolve symbol class Scanner (Error)
For whatever reason I get the error message "cannot resolve symbol class Scanner" when trying to run this:
import java.io.*;
import java.util.*;
public class NameReversal
public static void main(String args[])
System.out.print("Enter your name: ");
Scanner Reader = new Scanner(System.in);
String first = Reader.next();
String finl = Reader.next();
int z = first.length();
int v = finl.length();
int y = z-1;
int f = y-1;
for(int i = y; i>=0; z--)
System.out.print(first.charAt(1));
System.out.print(" ");
for(int p = f; p >= 0; p--)
System.out.println(finl.charAt(p));
}The Scanner class is in the JDK version 1.5 or later. You must be using an earlier version.
-
Error:cannot resolve Symbol class"name"
when I have compiled Bean class named SlBean which has primary class named pk, I recevied following error message(I compiled pk class without error) :
cannot resolve symbol
symbol : class pk
location: class SlBean
public pk ejbCreate(Sorry , its not classpath problem. You have to simply import the pk class if its in any package. I am assuming you have packaged your pk class with ejb jar file.
for eg. if your class is
package abc.xyz
public class pk
then in your bean class import
import abc.xyz.pk;
--Ashwani -
Import java.util.Formatter - cannot resolve symbol
I use j2sdk1.4.2_04
when I try to compile my program using Formatter, it response error "cannot resolve symbol"
Pls help!Where did you get this java.util.Formatter from? If you check the official 1.4.2 API for Java, that class does not exisit! However, java.util.logging.Formatter, does exisit...
http://java.sun.com/j2se/1.4.2/docs/api/
If you ment: java.util.logging.Formatter have you checked the API to make sure you are using it correctly???
HTH.
Maybe you are looking for
-
Safari 6.1 problem with Java
Have OS X 10.8.5 Last Nov. Safari wouldn't work at all with Java. Many of us had this problem and had to uninstall it, and go back to 6.0.5 -- which we were told takes a long time..actually took about 10-12 hrs to download. It's been 4 months. I'd
-
Hello, Could someone tell me how the open deliveries, open billing documents and open orders value get updated in FD33. (Extras -> Sales value). I am trying to find out when a sales order gets included in open delivery, when it comes under open billi
-
Best way to include appendices to pages document
I am trying to transition from using MS office (for over a decade now) to using the Apple suite of apps. I am in grad school so I write a lot of papers. I am working on one now that requires appendices at the end. I am working on the paper in section
-
Is there a default location for message tracking logs on Exch2010? And what format are they in? can they be analysed in any other tool than exchange, if for example you had recovered the logs from a backup?
-
I am unable to access Weather on my iPod of version 6.0
I am unable to access Weather on my iPod touch 4th gen.