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

Similar Messages

  • 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,
    Anup

    cannot resolve symbol ,Syntax error in source
    indicates some jar file is not in the Classpath. Is j2ee.jar in the Classpath?

  • 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.

  • Import javax.ejb cannot be resolved

    Hi,
    There are some libraries missing in the following code.
    package era.budget;
    import javax.ejb.*;
    import era.budget.BudgetVO;
    public class BudgetItemVO implements java.io.Serializable
         private Integer itemId;
         private BudgetVO budget;
         private int type;
         private String itemDetails;
         private int amount;
    // -------------- BEGIN GET/SET METHODS --------------
    public BudgetItemVO(Integer id)
              this.itemId = id;
         public BudgetItemVO()
         public Integer getItemId()
              return itemId;
    public BudgetVO getBudget()
              return budget;
         public void setBudget(BudgetVO budget)
              this.budget=budget;
    public int getType()
              return type;
         public void setType(int id)
         this.type=id;
    public String getItemDetails()
              return this.itemDetails;
    public void setItemDetails(String details)
              this.itemDetails=details;
    public int getAmount()
              return this.amount;
    public void setAmount(int amount)
    this.amount=amount;
    As aresult of these missing libraries there are some compilation errors..Some of the errors are as follows
         1)The import javax.ejb cannot be resolved     
         2)EntityBean cannot be resolved to a type     
    3)EntityContext cannot be resolved to a type     
    4)EJBLocalObject cannot be resolved to a type     
    Thanx & Regards
    Maria.

    try: in your project properties choose 'Java Build Path' and add javaee.jar (from J2EE_HOME\lib) as external jar

  • Package javax.servlet does not exists - Cannot resolve symbol

    Hello,
    I am using JDK 1.3.1.06 version. I wanted to compile a simple servlet using this. But I am getting plenty of errors for all javax package. Why it is not able to find javax package classes?
    The following is the program I have tried to compile.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class TestServlet extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    process(request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    process(request, response);
    private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    PrintWriter out = response.getWriter();
    out.println("Hello World !");
    I am getting errors like this :
    Package javax.servlet does not exists.
    cannot resolve symbol
    symbol : class HttpServlet
    Please advice me some solutions fast.
    Thanking you,
    ForumAns.

    javax.servlet doesn't come with the standard jdk. It's part of J2EE.
    If you have tomcat, you can use the server.jar that comes with tomcat.
    Or you can just download J2EE sdk instead.
    I am getting errors like this :
    Package javax.servlet does not exists.
    cannot resolve symbol
    symbol : class HttpServlet

  • 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 : import

    I've never had this type of error while doing a compile before.
    Does this mean that java doesn't know where to find my org.nipr.gateway_ws.utils.ConnectionPoolSingleton?
        [javac] Compiling 1 source file to C:\Data\StateProcessWebService\Server\build\war\WEB-INF\classes
        [javac] C:\Data\StateProcessWebService\Server\src\org\nipr\StateProcess\impl\StateProcessImpl.java:20: cannot resolve symbol
        [javac] symbol  : class ConnectionPoolSingleton
        [javac] location: package utils
        [javac] import org.nipr.gateway_ws.utils.ConnectionPoolSingleton;
        [javac] ^
        [javac] C:\Data\StateProcessWebService\Server\src\org\nipr\StateProcess\impl\StateProcessImpl.java:265: cannot resolve symbol
        [javac] symbol  : variable ConnectionPoolSingleton
        [javac] location: class org.nipr.StateProcess.impl.StateProcessImpl
        [javac] ConnectionPooler pool = ConnectionPoolSingleton.instance( "stateProcess" );
        [javac] ^

    Cool. Thanks.
    I freaked when I first saw that. I added the missing java file and it compiled just fine.

  • '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.
    2Willis4

    Hi 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.

  • "Cannot resolve symbol" error when importing a package

    I'm new to Java and have been trying to make use of a toolikt which uses an imported package. Basically my problem is that I've been trying to compile a file called CookBook.java which contains the following import statements at the top of the file:
    package gate;
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import junit.framework.*;
    import gate.*;
    import gate.util.*;
    import gate.creole.*;
    import gate.creole.nerc.*;
    I then compile this using the following command line:
    /cygdrive/c/jdk1.3.1_01/bin/javac.exe      \
         -classpath "C:\cygwin\home\stevens1\gate_src\gate\build\gate.jar" \
         -extdirs "C:\cygwin\home\stevens1\gate_src\gate\lib\ext"     \
         -d . CookBook.java
    (The extdirs command is required, acording to the manual, because the toolkit is implemented as two files for security reasons: gate.jar and guk.jar) These two flags should point to all the .jar files required by the application.
    However, that command produces the following errors:
    CookBook.java:140: cannot resolve symbol
    symbol : method assertTrue (java.lang.String,boolean)
    location: class gate.CookBook
    assertTrue(
    ^
    CookBook.java:146: cannot resolve symbol
    symbol : variable GateConstants
    location: class gate.CookBook
    GateConstants.ORIGINAL_MARKUPS_ANNOT_SET_NAME);
    ^
    CookBook.java:152: cannot resolve symbol
    symbol : method assertTrue (java.lang.String,boolean)
    location: class gate.CookBook
    assertTrue(
    ^
    One thing I've not been clear on is whether the files (CookBook.java) need to be in a directory with a special name. I've tried playing about with different ones but without much success.
    Any suggestions to help a completely confused Java rookie would really be apreciated!
    thanks in advance
    mark

    I then compile this using the following command line:
    /cygdrive/c/jdk1.3.1_01/bin/javac.exe \
    -classpath "C:\cygwin\home\stevens\gate_src\gate\build\gate.jar" \
    -extdirs "C:\cygwin\home\stevens1\gate_src\gate\lib\ext" \
    -d . CookBook.javaThere are a couple of issues with your compile...
    Most notably, by setting the classpath to your build jar, you are compiling against old classes. If you set your classpath rather to the base of your package hierarchy, then javac will to some degree review and recompile dependencies, against your current source files. If you specify a target directory with -d, class files will be examined in this location if they aren't in the class path (And their source file is not in the compile-path)
    Also, if you are compiling packages, I've found a good practice to be to compile from the base of the package structure, so your command will be more likejavac \
    -classpath . \
    -extdirs "C:\cygwin\home\stevens1\gate_src\gate\lib\ext" \
    gate\\CookBook.javaIt seems to make it easier for the compiler to 'correctly' look up dependencies.
    Hope that helps, at least a little,
    -Troy

  • Cannot resolve symbol: class EJBObject

    Using javac I get this compile error on this file Calculator.java
    Calculator.java:1: cannot resolve symbol
    symbol : class EJBObject
    location: package ejb
    import javax.ejb.EJBObject;
    ^
    Calculator.java:5: cannot resolve symbol
    symbol : class EJBObject
    location: interface Calculator
    public interface Calculator extends EJBObject {
    Source code for Calculator.java
    import javax.ejb.EJBObject;
    import java.rmi.*;
    public interface Calculator extends EJBObject {
         public long add (int x, int y) throws RemoteException;
         public long subtract (int x, int y) throws RemoteException;

    This code is from a book, so I will assume its a classpath problem. My
    classpath looks like:
    "C\QTJava.zip".;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib\locale
    Also the following enviorment varibales have been set to:
    J2EE_HOME
    C:\Development\Java\j2sdkee1.3.1
    JAVA_HOME
    C:\Development\Java\jdk1.3.1
    Path
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;%JAVA_HOME%\bin;%J2EE_HOME%\bin
    I can run j2EE, like "j2EE -verbose" (no problems)
    also run cloudscape, like "cloudscape -start" (no problems)
    also can run deploytool, like "deploytool" (no problems, & deploy sample ear files from cd book)
    Your help is appreicated.

  • Compilation problem (cannot resolve symbol)

    I have searched the Forums for "cannot resolve symbol" and as usual, many posts with no answers or just advise that noone ever comes back to say works. I am trying to compile this code:
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import org.acme.*;
    public class HelloOpenEJB extends HttpServlet {
    String factory = "org.openejb.client.LocalInitialContextFactory";
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    try{
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, factory );
    InitialContext ctx = new InitialContext( p );
    //Lookup the bean using it's deployment id
    Object obj = ctx.lookup("/Hello");
    HelloHome ejbHome = (HelloHome) obj;
    //Use the HelloHome to create a HelloObject
    HelloHome ejbHome = (HelloHome)
    PortableRemoteObject.narrow(obj, HelloHome.class);
    //The part we've all been wainting for...
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");
    out.println("<title>Hello World!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>"+ ejbObject.sayHello() +"</h1>");
    out.println("</body>");
    out.println("</html>");
    } catch (Exception e){
    response.setContentType("text/plain");
    e.printStackTrace(out);
    I'm running this on a Linux box. When I compile, I get this:
    HelloOpenEJB.java:28: ejbHome is already defined in doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    HelloHome ejbHome = (HelloHome)
    ^
    HelloOpenEJB.java:29: cannot resolve symbol
    symbol : variable PortableRemoteObject
    location: class HelloOpenEJB
    PortableRemoteObject.narrow(obj, HelloHome.class);
    ^
    HelloOpenEJB.java:38: cannot resolve symbol
    symbol : variable ejbObject
    location: class HelloOpenEJB
    out.println(""+ ejbObject.sayHello() +"");
    ^
    3 errors
    I don't know why any of these errors are occuring, besides the obvious responses given back from javac, so can someone help? Thanks, Jeremy

    The error message "x already defined in y" means that you're trying to use a name that already exists in the current scope. In your case you have:
    HelloHome ejbHome = (HelloHome) obj;
    //Use the HelloHome to create a HelloObject
    HelloHome ejbHome = (HelloHome)
    PortableRemoteObject.narrow(obj, HelloHome.class);Here you are trying to declare two instances of HelloHome with the same name.
    The reason that you would get "cannot resolve symbol" is that you are trying to access a variable or class that you haven't declared or imported.

  • EJBObject Cannot Resolve Symbol

    Hi,
    I am new to EJB, i have a class converter,
    import javax.ejb.EJBObject;
    import java.awt.*;
    import java.rmi.*;
    public interface converter extends EJBObject{
         public double dollartorupee(double d)throws RemoteException;
         public double rupeetodollar(double d)throws RemoteException;
    When i complie this i recive an error,
    C:\>javac converter.java
    converter.java:2: cannot resolve symbol
    symbol : class EJBObject
    location: package ejb
    import javax.ejb.EJBObject;
    ^
    converter.java:6: cannot resolve symbol
    symbol : class EJBObject
    location: interface converter
    public interface converter extends EJBObject{
    ^
    2 errors
    Can Someone Plz Help me out with this. Thank you.

    Even if you include $J2EE_HOME/lib/j2ee.jar in your classpath , the compiler will not find the EJBObject class. I unpacked the j2ee.jar and found out that there is no ejb directory in the jar. I have the J2EE1.3.1 distribution for Linux. I think that Sun have not included ejb in the Linux distribution . If this is true , it is either a big mistake or something they did on purpose.

  • "cannot resolve symbol" in a Timer !!!Please Help!!!

    I am doing a program for a class which involves timers. I am using JCreator and when i try to construct a new timer, the compiler points to the "new" in the line:
    Timer T1=new Timer(interval, ActionListener);
    ^
    This is what it looks like and the error reads: cannot resolve symbol; constructor Timer.
    please tell me if yiou have any information or suggestions as to how this error might be remedied.

    Sure, here it is:
    import java.awt.event.*;
    import javax.swing.Timer;
    import javax.swing.JOptionPane;
    import java.util.*;
    interface ActionListener
         void actionPerformed(ActionEvent event);     
    class Ploid
         public static void main(String[] args)
              class Car implements ActionListener
                   int mpg=30;
                   int mph=35;
                   int gtank=20;
                   int interval;
                   int changer;
                   int totalmiles;
                   Car(int x)
                        interval=x;
                   public void actionPerformed(ActionEvent event)
                        for(int c=0;c<(interval/1000);c++)
                             totalmiles=totalmiles+mph;
                        int hyt=mpg*gtank;
                        if(totalmiles>hyt)
                             int y=totalmiles-hyt;
                             totalmiles=totalmiles-y;
                             System.out.println(totalmiles);
                        else
                             System.out.println(totalmiles);
    class SUV implements ActionListener
         int mpg=15;
         int mph=55;
         int gtank=30;
         int interval;
         int changer;
         int totalmiles;
         SUV(int x)
              interval=x;
              public void actionPerformed(ActionEvent event)
                   for(int c=0;c<(interval/1000);c++)
                        totalmiles=totalmiles+mph;
                   int hyt=mpg*gtank;
                   if(totalmiles>hyt)
                        int y=totalmiles-hyt;
                        totalmiles=totalmiles-y;
                        System.out.println(totalmiles);
                   else
                        System.out.println(totalmiles);
    class Semi implements ActionListener
         int mpg=60;
         int mph=80;
         int gtank=50;
         int interval;
         int changer;
         int totalmiles;
         Semi(int x)
              interval=x;
         public void actionPerformed(ActionEvent event)
              for(int c=0;c<(interval/1000);c++)
                   totalmiles=totalmiles+mph;
              int hyt=mpg*gtank;
              if(totalmiles>hyt)
                   int y=totalmiles-hyt;
                   totalmiles=totalmiles-y;
                   System.out.println(totalmiles);
              else
                   System.out.println(totalmiles);
              String flag="y";
              String trav=JOptionPane.showInputDialog("How long do you want to drive?(1000=1 hour)");
              int t1=Integer.parseInt(trav);
              Car listen=new Car(t1);
              SUV listener2=new SUV(t1);
              Semi listener3=new Semi(t1);
              final int t2=t1/1000;
              final int t3=t1/t2;
              ActionListener listener=null;
              Timer T1=new Timer(t3, listener);
              Timer T2=new Timer(t3, listener);
              Timer T3=new Timer(t3, listener);
              while(flag.equals("y"))
                   T1.start();
                   T2.start();
                   T3.start();
                   String g=JOptionPane.showInputDialog("Do you want to drive again?");
                   if((g.equals("y"))||(g.equals("Y")))
                        System.out.println("Let's Drive!");
                   else
                        flag=g;
                   System.exit(0);
    }Here is the errors:
    [errors]
    A:\Ploid2.java:116: cannot resolve symbol
    symbol : constructor Timer (int,ActionListener)
    location: class javax.swing.Timer
              Timer T1=new Timer(t3, listener);
    ^
    A:\Ploid2.java:117: cannot resolve symbol
    symbol : constructor Timer (int,ActionListener)
    location: class javax.swing.Timer
              Timer T2=new Timer(t3, listener);
    ^
    A:\Ploid2.java:118: cannot resolve symbol
    symbol : constructor Timer (int,ActionListener)
    location: class javax.swing.Timer
              Timer T3=new Timer(t3, listener);
    ^
    3 errors
    Process completed.
    [errors]
    ****There is the source code and the errors the compiler returns. That should be more help.****

  • 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 CenterPanel

    There 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 class graphics

    does anyone know what the error
    cannot resolve symbol class graphics means?
    with this code i can't seem to call the graphics method to draw the line....any reason why?
    import javax.swing.*;
    import java.*;
    public class LineDraw extends JFrame {
        public static void main(String[] args) {
            LineDraw ld = new LineDraw();
            ld.setSize(500,500);
            ld.setVisible(true);
            ld.enterVariables();
        public void init(){
        private int x1;
        private int x2;
        private int y1;
        private int y2;
        public void paint(Graphics g) {
            g.GetGraphics(g);
            super.paintComponent(g);
            g.drawLine(x1, y1, x2, y2);
        public void enterVariables() {
            x1 = Integer.parseInt(JOptionPane.showInputDialog("Enter x1:"));
            y1 = Integer.parseInt(JOptionPane.showInputDialog("Enter y1:"));
            x2 = Integer.parseInt(JOptionPane.showInputDialog("Enter x2:"));
            y2 = Integer.parseInt(JOptionPane.showInputDialog("Enter y2:"));
            repaint();
    }

    well the exact error message is ...by the way now that i think about it
    if the graphics method shoudl not be part of the JFrame class then what method would i use to draw 2D Graphics?
    --------------------Configuration: <Default>--------------------
    C:\Documents and Settings\c1s5\My Documents\LineDraw.java:21: cannot resolve symbol
    symbol : class Graphics
    location: class LineDraw
    public void paint(Graphics g)
    ^
    1 error
    Process completed.
    and the exact code is
    import javax.swing.*;
    import java.*;
    public class LineDraw extends JFrame {
        public static void main(String[] args) {
            LineDraw ld = new LineDraw();
            ld.setSize(1024,500);
            ld.setVisible(true);
            ld.enterVariables();
        private int x1;
        private int x2;
        private int y1;
        private int y2;
        public void paint(Graphics g)
            super.paintComponent(g);
            g.drawLine(x1, y1, x2, y2);
        public void enterVariables() {
            x1 = Integer.parseInt(JOptionPane.showInputDialog("Enter x1:"));
            y1 = Integer.parseInt(JOptionPane.showInputDialog("Enter y1:"));
            x2 = Integer.parseInt(JOptionPane.showInputDialog("Enter x2:"));
            y2 = Integer.parseInt(JOptionPane.showInputDialog("Enter y2:"));
            repaint();
    }

Maybe you are looking for