Cannot find javac compiler

I have recently installed apache tomcat and the J2SE SDk on my windows machine and have managed to get tomcat to run. However, when i try to test a jsp page I get an error saying ii cannot find the javac compiler. The error I amgetting is shown below.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
     org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
     org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
     org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
     org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
     org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
     org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
     org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I have checked my environment variables that I set up and I cannot finad anything wrong with them as they all seem to point to the right directory. Here are my environment variables.
CLASSPATH = C:\jdk1.5.0_02\lib\tools.jar;C:\Servers\Tomcat 5.0\common\lib\servlet-api.jar;C:\Servers\Tomcat 5.0\common\lib\jsp-api.jar
JAVA_HOME = C:\jdk1.5.0_02
PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\ATI-CPanel;C:\Program Files\Pragma\Clients;C:\Program Files\MySQL\MySQL Server 4.1\bin;C:\jdk1.5.0_02\bin
Does anyone have any idea what the problem could be? Any solutions would be much appreciated.
Thanks

I have recently installed apache tomcat and the J2SE SDk on my windows machine and have managed to get tomcat to run.
the error i have got is below:
Exception:
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
     at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
     at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
     at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
     at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:282)
     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
     at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
     at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
     at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
     at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
     at java.lang.Thread.run(Thread.java:536)
Does anyone have any idea what the problem could be? Any solutions would be much appreciated.
Thanks

Similar Messages

  • My system cannot find javac!!

    This is enough to drive me crazy. I use TextPad to develop Java apps, etc. One nice thing about it is, like other IDE's, you can compile and launch apps from within TextPad itself. One day, it just stopped being able to find the compiler. It finds the interpreter ok (AND THEY ARE IN THE SAME SPOT!). Well, I thought it was TextPad or something, but I just downloaded a web server to run my jsp pages and even though I have the bin folder of the jdk I want to use on my PATH, it (the jsp engine) cannot find the compiler! What the heck is going on? If I open a dos shell and type "java", it runs the interpreter (it finds it). If I type "javac" - I get "Exception in thread 'main' java.lang.NoClassDefFoundError: sun/tools/javac/Main"
    Why can't my system recognize my compiler? I have tried adjusting my path to an different jdk (bin folder) and the same thing happens! Arggh - help, please!

    It seems that u have installed JRE or other s/w like netscape, opera which gives JRE with them.
    Now when u installed it, it overrides (better to say append) the ur system's path / classpath variable, now as u know what is JRE, it has only interpreter java, but not compiler javac.
    So better to put ur jdk/bin path/classpath at last, in ur variable or autoexec.bat, whatever u used.
    let's see what happen?
    Hardik

  • Antinstaller - unable to find javac compiler

    Hi all,
    am using antinstaller to deploy an application. The application which I want to
    deploy has its own build file it has targets like clean, build, warfile etc. Its is working fine if an using ant from command prompt. but if I use ant installer
    and call this build.xml using the
    <ant dir="some dir" target="build" />
    then when ant installer runs as it comes to this line it give me error that
    Unable to find javac compiler com.sun.tools.javac.Main is not on the classpath
    perhaps JAVA_HOME does not point to the JDK.
    As I have already set JAVA_HOME to the jdk dir and PATH variable to
    %JAVA_HOME%\bin.
    Am not getting where the problem is - any suggestion is helpful.

    sorry, I forgot to add fork="true" to <javac> task

  • Cannot find javac.exe in j2se 1.5.0 jdk

    hi
    i have been installing and reinstalling JDK 5.0, yes it is jdk not jre...
    and i cannot find javac.exe
    does anyone has any solution?
    thanks in advance.

    Oh, and btw, you should uninstall everything (J2EE, J2RE/jre, Forte/S1S, and Webstart) - Then install J2SE, followed by J2EE, then S1S.
    Don't install J2RE as a separate install - the J2SE install will also install it and Webstart.

  • Compile error : "unable to find javac compiler"

    Hello,
    I've got this problem compiling my java project: the error that I get is :
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.5.0_05\lib\tools.jar
    init:
    compile:
    [javac] Compiling 9 source files to H:\project\class
    BUILD FAILED
    H:\project\build.sml:8: Unable to find a javac compiler;
    com.sun.tools.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to th JDK
    I'm using the following product:
    a)     MySQL Database: mysql-4.1.13a-win32.zip (http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.13a-win32.zip/from/pick)
    b)     MySQL JDBC driver: mysql-connector-java-3.1.10.zip (http://dev.mysql.com/downloads/connector/j/3.1.html )
    c)     JBuilder 2005: http://www.borland.com/downloads/download_jbuilder.html
    d)     Jakarta Ant: apache-ant-1.6.5-bin.zip (http://ant.apache.org/bindownload.cgi)
    In the C:\Program Files\JAVA map are the following maps:
    - jdk1.5.0_05
    - jre1.5.0_05
    the settings in windows:
    ANT_HOME C:\java\apache-ant-1.6.5
    JAVA_HOME C:\Program Files\Java\jdk1.5.0_05
    And I have added ;C:\java\apache-ant-1.6.5\bin; to the PATH
    Why doesn't it work ? And more important, How can I fix it ?
    Thanks
    Nick

    Hello,
    I've got this problem compiling my java project: the error that I get is :
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.5.0_05\lib\tools.jar
    init:
    compile:
    [javac] Compiling 9 source files to H:\project\class
    BUILD FAILED
    H:\project\build.sml:8: Unable to find a javac compiler;
    com.sun.tools.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to th JDK
    I'm using the following product:
    a)     MySQL Database: mysql-4.1.13a-win32.zip (http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.13a-win32.zip/from/pick)
    b)     MySQL JDBC driver: mysql-connector-java-3.1.10.zip (http://dev.mysql.com/downloads/connector/j/3.1.html )
    c)     JBuilder 2005: http://www.borland.com/downloads/download_jbuilder.html
    d)     Jakarta Ant: apache-ant-1.6.5-bin.zip (http://ant.apache.org/bindownload.cgi)
    In the C:\Program Files\JAVA map are the following maps:
    - jdk1.5.0_05
    - jre1.5.0_05
    the settings in windows:
    ANT_HOME C:\java\apache-ant-1.6.5
    JAVA_HOME C:\Program Files\Java\jdk1.5.0_05
    And I have added ;C:\java\apache-ant-1.6.5\bin; to the PATH
    Why doesn't it work ? And more important, How can I fix it ?
    Thanks
    Nick

  • Error  "unable to find javac compiler"

    Hello,
    I've got this problem compiling my java project: the error that I get is :
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.5.0_05\lib\tools.jar
    init:
    compile:
    [javac] Compiling 9 source files to H:\project\class
    BUILD FAILED
    H:\project\build.xml:8: Unable to find a javac compiler;
    com.sun.tools.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK
    I'm using the following products:
    a) MySQL Database: mysql-4.1.13a-win32.zip (http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.13a-win32.zip/from/pick)
    b) MySQL JDBC driver: mysql-connector-java-3.1.10.zip (http://dev.mysql.com/downloads/connector/j/3.1.html )
    c) JBuilder 2005: http://www.borland.com/downloads/download_jbuilder.html
    d) Jakarta Ant: apache-ant-1.6.5-bin.zip (http://ant.apache.org/bindownload.cgi)
    In the C:\Program Files\JAVA map are the following maps:
    - jdk1.5.0_05
    - jre1.5.0_05
    the settings in windows:
    ANT_HOME C:\java\apache-ant-1.6.5
    JAVA_HOME C:\Program Files\Java\jdk1.5.0_05
    And I have added ;C:\java\apache-ant-1.6.5\bin; to the PATH
    Why doesn't it work ? And more important, How can I fix it ?
    Thanks
    Nick

    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=687035

  • Cannot find javac

    I am running Red Hat 7.3 and I just installed java 2 sdk from Sun's website, I updated the path for the java directory I installed it to, but I cant compile any files. I did a search for the "javac" file and it isnt anywhere on my system. The "java" file is there but not javac. can any one please help this has been driving me crazy for days!

    You may have installed the JRE rather than the JDK, which won't have the javac tool. Check to be sure you downloaded the correct file.

  • Cannot find javac program

    Hello, I just recently installed Java 2 SDK, version 1.3.1 on my NT computer. After installation (went
    by the book according to the java installation notes) and adding my path, I did a quick check in the
    folder I installed to..in this cas C:\jdk1.3 . I do not see the javac.exe file listed in the bin at all (there is a javaw and java but no javac). I reinstalled it just to see if I was incorrect and I still don't see it at all so of course I can't really run anything as of yet. I downloaded from this website. Can anyone help me?

    you should right-click the folder that contains jdk1.3 and click on "search" and then type the file name to search for wherever it is. Hope that helps any!
    james
    Hello, I just recently installed Java 2 SDK, version
    1.3.1 on my NT computer. After installation (went
    by the book according to the java installation notes)
    and adding my path, I did a quick check in the
    folder I installed to..in this cas C:\jdk1.3 . I do
    not see the javac.exe file listed in the bin at all
    (there is a javaw and java but no javac). I
    reinstalled it just to see if I was incorrect and I
    still don't see it at all so of course I can't really
    run anything as of yet. I downloaded from this
    website. Can anyone help me?

  • Javac = "cannot find symbol" when compiling class referencing other classes

    I have several Java files in a directory which is declared as a package at the start of the files
    package filemanager;
    This program works perfectly in an IDE, however I'm having problems with compiling in command line.
    I have set the classpath as I understand to be right for my computer to:
    C:\Program Files\Java\jdk1.6.0_02\bin
    I can compile a class that references no other classes in this package/directory.
    However files which reference other classes bring up such errors:
    javac AllFiles.javaAllFiles.java:174: cannot find symbol
    symbol : variable Bob
    location : class filesmanager.AllFiles
    Bob.getItem(itemRef);
    Where Bob is an example of another class. Even though I can say, compile Bob on it's own as it doesnt have any such reference.
    I've tried:
    javac -cp "C:\Program Files\Java\jdk1.6.0_02\bin" AllFiles.javaThis also failed.
    Any ideas?
    Edited by: ajr87 on Feb 8, 2008 10:26 AM

    I've tried spoon_'s suggestion, but I'm still getting the error ("cannot find symbol"). Here is my code:
    File Hello/Fred.java:
    package Hello;
    public class Fred
        public int age;
        public Fred()
            this.age = 1;
    } // public class FredFile Hello/Hello.java:
    package Hello;
    public class Hello
        public static void main(String args[])
            Fred fred = new Fred();
            System.out.println("Fred is " + fred.age);
    } // public class HelloAnd here is my attempt to compile Fred.java and Hello.java:
    C:/Users/levner/programs[219]javac -cp c:\users\levner\programs\hello Hello\Fred.java
    C:/Users/levner/programs[220]javac -cp c:\users\levner\programs\hello Hello\Hello.java
    Hello\Hello.java:14: cannot find symbol
    symbol  : class Fred
    location: class Hello.Hello
            Fred fred = new Fred();
            ^
    Hello\Hello.java:14: cannot find symbol
    symbol  : class Fred
    location: class Hello.Hello
            Fred fred = new Fred();
                            ^
    2 errorsI am doing this work on a PC running Vista using javac 1.6.0_10. I've tried various combinations of upper and lower case names for the package and file names, and I always get the same errors.
    Thanks in advance for your help. David

  • Error in Java compilation: \s7u.log (The system cannot find the file specified)

    Hi there,
    I got an error when I tried to compile a group of sqlj and java files. The error below:
    ----------------------------------------------sqlj -status -passes -compile=true -ser2class -d=. -classpath=.;%CLASSPATH% E:\work\src\java\com\interadnet\persistence\*.sqlj E:\work\src\java\com\interadnet\persistence\*.java
    out [Translating 53 files]
    out [Reading file AdServerInformationType]
    out [Reading file AdsType]
    out [Reading file AgencyType]
    out [Reading file CampaigntocompletionType]
    out [Reading file CampaignType]
    out [Reading file ChannelType]
    out [Reading file ClientType]
    out [Reading file CompletionType]
    out [Reading file ContactType]
    out [Reading file CreativeType]
    out [Reading file FtpServerType]
    out [Reading file InsertioninstructionType]
    out [Reading file MediaServerType]
    out [Reading file SystemPropertyType]
    out [Reading file VendorType]
    out [Reading file AdServerInformationTypeRef]
    out [Reading file AdServerInformationView]
    out [Reading file AdsTypeRef]
    out [Reading file AdsView]
    out [Reading file AgencyTypeRef]
    out [Reading file AgencyView]
    out [Reading file CampaigntocompletionTypeRef]
    out [Reading file CampaignToCompletionView]
    out [Reading file CampaignTypeRef]
    out [Reading file CampaignTypeRefs]
    out [Reading file CampaignView]
    out [Reading file ChannelTypeRef]
    out [Reading file ChannelTypeRefs]
    out [Reading file ChannelView]
    out [Reading file ClientTypeRef]
    out [Reading file ClientTypeRefs]
    out [Reading file ClientView]
    out [Reading file CompletionTypeRef]
    out [Reading file CompletionTypeRefs]
    out [Reading file CompletionView]
    out [Reading file ContactTypeRef]
    out [Reading file ContactView]
    out [Reading file CreativeTypeRef]
    out [Reading file CreativeTypeRefs]
    out [Reading file CreativeView]
    out [Reading file FtpServerTypeRef]
    out [Reading file FtpServerView]
    out [Reading file InsertioninstructionTypeRef]
    out [Reading file InsertioninstructionTypeRefs]
    out [Reading file InsertionInstructionView]
    out [Reading file MediaServerTypeRef]
    out [Reading file MediaServerView]
    out [Reading file SystemPropertyTypeRef]
    out [Reading file SystemPropertyTypeRefs]
    out [Reading file SystemPropertyView]
    out [Reading file VendorTypeRef]
    out [Reading file VendorTypeRefs]
    out [Reading file VendorView]
    out [Translating file AdServerInformationType]
    out [Translating file AdsType]
    out [Translating file AgencyType]
    out [Translating file CampaigntocompletionType]
    out [Translating file CampaignType]
    out [Translating file ChannelType]
    out [Translating file ClientType]
    out [Translating file CompletionType]
    out [Translating file ContactType]
    out [Translating file CreativeType]
    out [Translating file FtpServerType]
    out [Translating file InsertioninstructionType]
    out [Translating file MediaServerType]
    out [Translating file SystemPropertyType]
    out [Translating file VendorType]
    out [Translating file AdServerInformationTypeRef]
    out [Translating file AdServerInformationView]
    out [Translating file AdsTypeRef]
    out [Translating file AdsView]
    out [Translating file AgencyTypeRef]
    out [Translating file AgencyView]
    out [Translating file CampaigntocompletionTypeRef]
    out [Translating file CampaignToCompletionView]
    out [Translating file CampaignTypeRef]
    out [Translating file CampaignTypeRefs]
    out [Translating file CampaignView]
    out [Translating file ChannelTypeRef]
    out [Translating file ChannelTypeRefs]
    out [Translating file ChannelView]
    out [Translating file ClientTypeRef]
    out [Translating file ClientTypeRefs]
    out [Translating file ClientView]
    out [Translating file CompletionTypeRef]
    out [Translating file CompletionTypeRefs]
    out [Translating file CompletionView]
    out [Translating file ContactTypeRef]
    out [Translating file ContactView]
    out [Translating file CreativeTypeRef]
    out [Translating file CreativeTypeRefs]
    out [Translating file CreativeView]
    out [Translating file FtpServerTypeRef]
    out [Translating file FtpServerView]
    out [Translating file InsertioninstructionTypeRef]
    out [Translating file InsertioninstructionTypeRefs]
    out [Translating file InsertionInstructionView]
    out [Translating file MediaServerTypeRef]
    out [Translating file MediaServerView]
    out [Translating file SystemPropertyTypeRef]
    out [Translating file SystemPropertyTypeRefs]
    out [Translating file SystemPropertyView]
    out [Translating file VendorTypeRef]
    out [Translating file VendorTypeRefs]
    out [Translating file VendorView]
    out [Compiling 53 Java files]
    err*** The following character string is too long:
    err***
    out Error in Java compilation: \s7u.log (The system cannot find the file specified)
    Any suggestion appreciated.
    Daniel Huang

    Having not seen this before, I assume that the issue is that the command line string is too long when Javac is invoked.
    Here are a few things to reduce the size of the command line:
    - do not use the CLASSPATH option, but set the CLASSPATH environment variable (you can to that in a .bat file)
    - do not provide the .java files but rely on the implicit make capability in both, the SQLJ translator and the Java compiler. (Note: you must mention all of the .sqlj files that your program requires, do not rely on implicit make to find all of those.)
    - you can perform the -ser2class conversion as a separate step (see the SQLJ FAQ), as well as the Java compilation
    - there may or may not be a facility in your operating system to increase the size of the environment (and this may or may not have an effect on the maximum command line length)
    - you could try to omit the -passes option and see if that helps (that may actually be where your invocation if failing in the first place, in that it cannot write to some temporary file).
    Let us know how it goes. Thanks!

  • Cannot find symbol error when compiling in different packages

    Hey all,
    I'm trying to divide my project into a sensible hierarchy. This is what I want:
    MyProject
    MyProject/src ................................. where all the source files are (no further directories)
    MyProject/classes
    MyProject/classes/Main.class
    MyProject/classes/classes2 ................ sorry for not being creative XD
    MyProject/classes/classes2/Age.classNow, Age uses Main, and this is where the trouble is. I'm using javac directly to compile Age, and this is how I'm doing it:
    //from MyProject
    javac -cp classes src/Age.javaAnd I get this error:
    bla bla bla...cannot find symbol
    symbol  : variable Main
    location: class classes2.Age
              years = (byte)(Main.year - m.getYear());
                             ^Main is already compiled and in place.
    Also, this is how Age.java starts:
    package classes2;
    public class Age
    {...etcI'm using JCreator as an IDE (and using it's own build function, the same error occurs, which is why I tried directly compiling the file).
    Why can't javac find Main.class? I tried searching Google, but my particular problem didn't seem to crop up.
    Hope I provided enough information, and ask if more is needed.
    Many thanks :)

    If Main is not in a package (which it appears not to be), then it cannot be referenced by any class that is in a package. If Main is in a package, then you'll need to refer to it by it's fully-qualified name (or import it as such) if it's not in the same package as the class that's referring to it, and Main.class will have to be in a directory that corresponds to its package.
    Also, though the compiler may not require it, your source code directory structure should match your package hierarchy.

  • Cannot find class in same directory during compilation

    hi
    i have two file hello.java & hi.java in same directory having simple println statements.
    hello.java
    public class hello {
      public static void main(String[] args) {
        System.out.println("hello");
        new hi();
    }hi.java
    class hi {
      hi() {
        System.out.println("hi");
    }hi.java has compiled
    but when i try to compile hello.java i get error saying "Cannot find symbol class hi"
    i've tried giving classpath pointing to current directory during compilation as
    javac -classpath . hello.java
    but this also does not work.
    Please let me know if i am missing anything?
    thanks in advance...

    The javac compiler uses the Classpath to find classes. If your directory structure is c:\myjava\buron\doeacc (for example) then you need to have c:\myjava in the Classpath when you compile. For example javac -classpath c:\myjava MainFrame.java

  • Compile error : Cannot find symbol

    hello, i'm having trouble compiling a bean that resorts to another bean's public operation. Im trying to make a shopping cart which takes individual item orders such as item name and quantity and place them within an array list called cart in another bean. The errors i get when im trying to compile is:
    cannot find symbol
    symbol : class OrderItem
    location: class beans.WidgetOrder
               public void setItem(OrderItem o){cart.add(o);}I've looked at other threads and heard that quicktime can intervein with the classpath, so i deleted that, and also checked that CLASSPATH is set to C:\Program Files\Java\jre1.6.0_04\lib\ext\QTJava which it is, but the javabeans are set in the same path so i don't know what difference that is.

    Are you using an IDE?
    Is the OrderItem class in the beans package?
    You should have a path structure like some/path/beans where the WidgetOrder.class file will reside inside the beans directory. If OrderItem is in the beans package, then when you compile you should use something like "javac -cp some/path WidgetOrder.java"

  • "cannot find symbol" error while compiling the RMI

    I am trying to implement a simple RMI.
    I have the following :
    1. HelloInterface which has the SayHello method defined.
    2. HelloImpl which has the implementation of Say Hello
    3. Server code
    4. Client code
    the HelloInterface compiles properly.
    but when i say javac HelloImpl
    package rmisample;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RemoteException;
    public class HelloImpl extends UnicastRemoteObject implements HelloInterface{ --> this is where i get the error
    /** Creates a new instance of HelloImpl */
    public HelloImpl()throws RemoteException {
    super();
    public String SayHello(String s) throws RemoteException
    return "hello" +s;
    I get the following error:
    C:\Myjava\RMISample\src\rmisample>javac HelloImpl.java
    HelloImpl.java:18: cannot find symbol
    symbol: class HelloInterface
    public class HelloImpl extends UnicastRemoteObject implements HelloInterface{
    All 4 files are in the same directory.
    Am not sure what is going wrong and am new to this.
    Edited by: topcatin on Sep 14, 2007 6:52 AM

    The problem is probably that the compiler can't find the file with that class definition.
    Try changing your javac call so that is starts off
    javac -classpath .
    The dot is important!
    If it works, then go read up on classpaths.

  • Cannot find symbol error when compiling from cmd

    When compile and running program from Eclipse 3.3 everything works fine, but when trying to compile from cmd I get this error:
    C:\TEMP\1>javac A.java
    A.java:38: cannot find symbol
    symbol : class SwingWorker
    location: package javax.swing
    import javax.swing.SwingWorker;
    ^
    A.java:48: cannot find symbol
    symbol : class SwingWorker
    location: class A
    class Task extends SwingWorker {
    ^
    A.java:109: cannot find symbol
    symbol : method addPropertyChangeListener(A)
    location: class A.Task
    task.addPropertyChangeListener(this);
    ^
    A.java:110: cannot find symbol
    symbol : method execute()
    location: class A.Task
    task.execute();
    ^
    java -version get back: java version "1.6.0_14"....
    now, if i copy .class file that Eclipse made and just execute thet .class file from cmd everything works fine.
    here is the code, but i think that problems is somwhere else. i tried to serach on google, but... :(
    import java.awt.BorderLayout;
    import java.awt.Cursor;
    import java.awt.Insets;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingWorker;
    public class A extends JPanel implements ActionListener, PropertyChangeListener {
        private JProgressBar progressBar;
        private JButton startButton;
        private JTextArea taskOutput;
        private Task task;
        class Task extends SwingWorker {
             * Main task. Executed in background thread.
    //        @Override
            public Void doInBackground() {
                 System.out.println("test");
                return null;
             * Executed in event dispatching thread
    //        @Override
            public void done() {
                Toolkit.getDefaultToolkit().beep();
                startButton.setEnabled(true);
                setCursor(null); //turn off the wait cursor
                taskOutput.append("Done!\n");
        public A() {
            super(new BorderLayout());
            //Create the demo's UI.
            startButton = new JButton("Start");
            startButton.setActionCommand("start");
            startButton.addActionListener(this);
            progressBar = new JProgressBar(0, 100);
            progressBar.setValue(0);
            progressBar.setStringPainted(true);
            taskOutput = new JTextArea(25, 50);
            taskOutput.setMargin(new Insets(5,5,5,5));
            taskOutput.setEditable(false);
            JPanel panel = new JPanel();
            panel.add(startButton);
            panel.add(progressBar);
            add(panel, BorderLayout.PAGE_START);
            add(new JScrollPane(taskOutput), BorderLayout.CENTER);
            setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
         * Invoked when the user presses the start button.
        public void actionPerformed(ActionEvent evt) {
            startButton.setEnabled(false);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            //Instances of javax.swing.SwingWorker are not reusuable, so
            //we create new instances as needed.
            task = new Task();
            task.addPropertyChangeListener(this);
            task.execute();
         * Invoked when task's progress property changes.
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress" == evt.getPropertyName()) {
                int progress = (Integer) evt.getNewValue();
                progressBar.setValue(progress);
    //            taskOutput.append(String.format("Completed %d%% of task.\n", task.getProgress()));
         * Create the GUI and show it. As with all GUI code, this must run
         * on the event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("Veritas Backup");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new A();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }thank you very much!!!!

    Perhaps you are running an older version of javac. What do you get with "javac -version" or try compiling with the full path to jdk 1.6.0_14/bin/javac.

Maybe you are looking for