Silly problem when compiling main class

hi there,
i have a problem when compiling the main class.
the classes used by the main class are not recognized. the compiler can't locate the children classes.
i've already set the path and classpath environment variables, but there's still something missing.
how should i organize my folders in order to be able to compile the main class successfully, please?
thanks.

It would be good to have a precise problem description: the actual command used, folder structure and environment variable settings. Even if you have to construct a simple test case with a couple of classes that illustrates the problem.
In the absence of that some generic remarks:
The PATH variable typically points at all the folders that contain executable files that you use often. You can always access other executable files by specifying there full names.
The CLASSPATH variable is typically left unset.
When you use the java tools (like the javac compiler or the java runtime) you can specify the classpath that you want to use with -cp. This will override any CLASSPATH value. So in the simple case of two classes (Main and MyClass), you can put them in anywhere you like (for example C:\MyJavaStuff) and compile and run with:
{noformat}
C:\MyJavaStuff> javac -cp . *.java
C:\MyJavaStuff> java -cp . Main
{noformat}(Mind the dot after -cp))
By a "main" class I guess you mean a class with a static void main(String args[]) method, but I am suspicious of your "child" classes. Perhaps packages are involved. A precise description of the problem would help.

Similar Messages

  • Java.lang symbols not found when compiling package classes

    I have a set of classes that I have wrapped up in a package. The package name and
    directory structure follow the standard required for each. These classes contain many
    java.lang.Math functions and java.lang.Double calls.
    Am I correct in that the java.lang functions will be imported automatically? When I
    compile a class that is in the package, it looks for the Math.pow (for example)
    function in the package instead of java.lang. I have tried putting the following include
    at the top:
    include java.lang.*;and I still get the "cannot resolve symbol" error. Only when I use
    include java.lang.Math;
    include java.lang.Double;does it compile properly. Is this indicative of a problem with my classpath? It is
    currently set to look in whatever the current directory is, the directory with src.jar,
    and my dev directory that contains the package I am working on.
    Please advise! Thanks in advance!
    Rodman

    Thanks for the quick reply! I looked in the package directory and found the Math.java and
    Double.java files. I'm not sure why they were there. Thanks again!

  • Create problem when compiling the servlet

    hi,
    i got a problem when i compile a servlet
    when i try to compile the servlet, it shows that it could
    not found the classes like httpservlet, etc.
    means the classes of the servlet
    i am using the j2sdk1.4.1 edition,
    i had include the javax.servlet.*; in the program
    please tell me what can be the problem & especially any solution for that

    the javax.servlet package and it's sub packages (javax.servlet.http, javax.servlet.jsp, javax.servlet.jsp.tagext) are not included with the Standard Edition. These packages are part of the Enterprise Edition. Check out this link for download:
    http://java.sun.com/j2ee/sdk_1.3/

  • Bug: Flash CS5+CS4 Professional crashes when compiling AS2 classes.

    My name is Mario Gomes Cavalcanti, I'm the CEO of Mersica Inc. and the developer of the free, online graphic design software, image and photo editor Fatpaint.com.
    Fatpaint is a Flash application, made using the Actionscript 2 programming language. This week we added some new functionality to the source code and after that, Flash CS5 professional IDE can no longer compile the project, it crashes on every attempt without any error messages.
    We are talking here about a huge project with around 360 Actionscript 2 classes. The size if the our last successful compiled SWF file was around 800 kilobytes. This compilation wa done last week, prior to the latest addition/modification of source files. The project is mostly made of Actionscript 2 source code, it do not have much other stuff in it.
    I would like assistence is resolving this issue... Why does Flash CS5 crash when compiling my Actionscript 2 classes?
    I would like to send the project and source files to the developers of the Flash actionscript 2 compiler, so they can see why it cannot compile my files.
    Fatpaint.com is probably the Flash application with the most sourcecode (classes) so I think it has something to do with that.
    My system:
    Windows 7 64bit
    Adobe Flash CS5 professional version 11.0.2.489
    Thank you.

    We managed to compile the project using Flash Pro 8, and we also got in touch with Adobe and sent them the source files of our Flash editor.
    It's been a month now and they still have not released a fix.

  • Problem when compiling TWIN

    When compiling TWIN from AUR (here), I got stuck at "make" phase. I download the tarball from AUR and makepkg from my home directory. The point at where I got stuck is this:
    libTw.c: In function 'Tw_Close':
    libTw.c:1224: error: invalid storage class for function 'DeleteAllListeners'
    libTw.c:1253: warning: implicit declaration of function 'DeleteAllListeners'
    libTw.c: In function 'Tw_StrError':
    libTw.c:1634: error: static declaration of 'DeleteAllListeners' follows non-static declaration
    libTw.c:1253: error: previous implicit declaration of 'DeleteAllListeners' was here
    make[2]: *** [libTw.o] Error 1
    make[2]: Leaving directory `/home/prasetya/Build/twin/src/twin-0.4.6/libs/libTw'
    make[1]: *** [build-dir-libTw] Error 2
    make[1]: Leaving directory `/home/prasetya/Build/twin/src/twin-0.4.6/libs'
    make: *** [build-dir-libs] Error 2
    ==> ERROR: Build Failed.
    Aborting...
    I have read this thread and have installed termcap-compat and required deps as mentioned. It configures fine.
    Any help is appreciated..

    Duplicate post, please go here:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=204588
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Llvm-g++ problems when compiling alchemy

    Hello community,
    I wanted to have a look at alchemy, so I installed cygwin and configured alchemy. However, I'm a little bit stucked... I did the steps in the tutorial but when compiling I got errors (note, I use g++ instead of gcc):
    $ alc-on && g++ c__/blackcat.c -O3 -Wall -swc -o swc/blackcat.swc
          3 [main] llvm-g++ 4360 child_copy: cygheap read copy failed, 0x61224780..0
    x6122A4C4, done 0, windows pid 4360, Win32 error 6
          3 [main] llvm-g++ 4656 child_copy: cygheap read copy failed, 0x61224780..0
    x6122A4C4, done 0, windows pid 4656, Win32 error 6
          3 [main] llvm-g++ 4816 child_copy: cygheap read copy failed, 0x61224780..0
    x6122A4C4, done 0, windows pid 4816, Win32 error 6
          3 [main] llvm-g++ 2792 child_copy: cygheap read copy failed, 0x61224780..0
    x6122A4C4, done 0, windows pid 2792, Win32 error 6
          4 [main] llvm-g++ 2264 child_copy: cygheap read copy failed, 0x61224780..0
    x6122A4C4, done 0, windows pid 2264, Win32 error 6
          3 [main] llvm-g++ 3368 child_copy: cygheap read copy failed, 0x61224780..0
    x6122A4C4, done 0, windows pid 3368, Win32 error 6
    So I tried different things like removing the symbolic links, then relinked them, copied alchemy again, reinstalled cygwin, installed cygwin onto another drive, copied flexsdk to c/flexsdk, but nothing of this did the job.
    Did anyone else had same errors?
    I'm running a german Windows 7 x86_64 version here.
    My business partner got it to work on his machine, but he also doesn't know why it's not working on mine.
    Can someone help?
    Kind Regards,
    Daniel

    This is an "invalid handle" error.
    The first thing to do is run your cygwin session as administrator.  If that doesn't fix it, I would check the file permissions on the drive.
    If the setup doesn't work properly (i.e. the symlinks don't get created properly), I don't think you even get this far, but that's something to check as well.  If your colleague has it working, you can compare your installs.

  • Codepage problem when compiling with fastjavac

    Hi,
    I'm getting the following warnings when compiling with fastjavac:
    fastjavac: warning: Can't find codepage for "Cp1250" encoding.
    fastjavac: warning: Use default ANSI codepage.
    2 warnings
    How could I suppress these warnings?
    Thanks in advance

    I think you are posting it on the wrong Forum. This is for Forte 4GL not Forte for Java.

  • Problem When Import Java Class -compilation error

    Hi all
    I made a java class that has methods to return Screen width and Height .
    package tarek;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    public class Screen
    Dimension dim ;
    public Screen()
    dim = Toolkit.getDefaultToolkit().getScreenSize();
    public double getWidth()
    double w = dim.getWidth();
    return w;
    public double getHeight()
    double h=dim.getHeight();
    return h;
    I made the jar file " screen.jar" and make it ready to use in form builder
    I opened form builder and make import java class (From program>import java class>choose the class anc click import)
    The class now imported successfully and the PL/SQL package body is:
    PACKAGE Screen /* tarek.Screen */ IS
    -- DO NOT EDIT THIS FILE - it is machine generated!
    -- Constructor for signature ()V
    FUNCTION new RETURN ORA_JAVA.JOBJECT;
    -- Method: getHeight ()D
    FUNCTION getHeight(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER;
    -- Method: getWidth ()D
    FUNCTION getWidth(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER;
    END;
    Now I made a button on the form and i WRITE THIS CODE TO INVOKE THE CLASS on when_button_pressed
    DECLARE
         vScreen_Class ORA_JAVA.JOBJECT;     
    BEGIN
         vScreen_Class := SCREEN.NEW;
    END;
    My problem is I have compilation error
    error 306 AT LINE 5 , COLUMN 25
    wrong number or types of argument in call to "NEW"
    I do not know what is the reason of this compilation error?
    Is it because the method in java return "double datatype" while in oracle return "number datatype"
    Please help
    Edited by: [email protected] on Dec 28, 2009 10:24 AM

    Sarah, I ca not move my thread to JDeveloper because it is not java issue. The problem is with my PL/SQL code and the way I make Import Java class to forms Builder. The Java code is OK.
    Andreas Thank you so much for replying. In fact I made a full compile "Ctrl+Alt+K". but still error
    The following is the package Body
    PACKAGE BODY Screen IS
    -- DO NOT EDIT THIS FILE - it is machine generated!
    args JNI.ARGLIST;
    -- Constructor for signature ()V
    FUNCTION new RETURN ORA_JAVA.JOBJECT IS
    BEGIN
    args := NULL;
    RETURN (JNI.NEW_OBJECT('tarek/Screen', '()V', args));
    END;
    -- Method: getHeight ()D
    FUNCTION getHeight(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
    BEGIN
    args := NULL;
    RETURN JNI.CALL_DOUBLE_METHOD(FALSE, obj, 'tarek/Screen', 'getHeight', '()D', args);
    END;
    -- Method: getWidth ()D
    FUNCTION getWidth(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
    BEGIN
    args := NULL;
    RETURN JNI.CALL_DOUBLE_METHOD(FALSE, obj, 'tarek/Screen', 'getWidth', '()D', args);
    END;
    BEGIN
    NULL;
    END;
    ---------------------------------------------------------------------------------

  • Package problem when compiling

    Hi,
    I'm new to java. I'm using Win2000 and JDK1.3.1. I set the "c:\jdk1.3.1\bin" in the System's path. There are three java programs with their own package in the directory as follows:
    "pack.java" - under "c:\jdk1.3.1\bin\test", it will call pack1 & pack2.
    "pack1.java" - under "c:\jdk1.3.1\bin\test\sub1"
    "pack2.java" - under "c:\jdk1.3.1\bin\test\sub2"
    It's ok to compile "pack1.java" and "pack2.java" under their directory. But there is the compiling error for the "pack.java" under "c:\jdk1.3.1\bin\test", even though I've put the "import test.sub1.pack1;" and "import test.sub2.pack2;" in the code. The error were as follows:
    - cannot resolve symbol
    - symbol : class pack1
    - location: package sub1
    - import test.sub1.pack1;
    - cannot resolve symbol
    - symbol : class pack2
    - location: package sub2
    - import test.sub2.pack2;
    I'm not sure what the problem is with the package and/or the import statement. Can any experts help me?
    Thanks in advance.
    Hanna

    Hi all gurus,
    Thank you very much for the help!
    After adding the classpath "c:\jdk1.3.1\bin" to the System's setting, I can compile the "pack.java" under the "test" directory with the command "javac -classpath c:\jdk1.3.1\bin c:\jdk1.3.1\bin\test\pack.java". However, when I run "pack" with the command "java -classpath c:\jdk1.3.1\bin c:\jdk1.3.1\bin\test\pack", there is another error appears as follows, although the "pack.class" has been already there:
    - "Exception in thread "main" java.lang.NoClassDefFoundError: c:\jdk1/3/1\bin\test\pack"
    My "pack.java" code is below:
    package test;
    import test.sub1.pack1;
    import test.sub2.pack2;
    class pack{
    public static void main(String[] args){
    System.out.println("Starting pack");
    System.out.println("Instantiate obj of public classes in different packages");
    //Instantiate objects of pack1 and pack2 in different packages.
    new pack1();
    new pack2();
    System.out.println("Ending pack");
    What's wrong with them? Could you please help me on that?
    Thanks again!
    Hanna

  • "cannot resolve symbol" when compiling a class that calls methods

    I am currently taking a Intro to Java class. This problem has my instructor baffled. If I have two classes saved in separate files, for example:
    one class might contain the constructor with get and set statements,
    the other class contains the main() method and calls the constructor.
    The first file compiles clean. When I compile the second file, I get the "cannot resolve symbol error" referring to the first class.
    If I copy both files to floppy and take them to school. I can compile and run them with no problem.
    If I copy the constructor file to the second file and delete the "public" from the class declaration of the constructor, it will compile and run at home.
    At home, I am running Windows ME. At school, Windows 2000 Professional.
    The textbook that we are using came with a CD from which I downloaded the SDK and Runtime Environment. I have tried uninstalling and reinstalling. I have also tried downloading directly from the Sun website and still the error persists.
    I came across a new twist tonight. I copied class files from the CD to my hard drive. 4 separate files. 3 of which are called by the 4th.
    I can run these with no problem.
    Any ideas, why I would have compile errors????
    Thanks!!

    Oooops ... violated....
    Well first a constructor should have the same name as the class name so in our case what we have actually created is a static method statementOfPhilosophy() in class SetUpSite and not a constructor.
    Now why does second class report unresolved symbol ???
    Look at this line
    Class XYZ=new XYZ();
    sounds familiar, well this is what is missing from your second class, since there is no object how can it call a method ...
    why the precompiled classes run is cuz they contain the right code perhaps so my suggestion to you is,
    1) Review the meaning and implementation of Constructors
    2) Ask your instructor to do the same ( no pun intended ... )
    3) Check out this for understanding PATH & CLASSPATH http://www.geocities.com/gaurav007_2000/java/
    4) Look at the "import" statement, when we have code in different files and we need to incorporate some code in another it is always a good idea to use import statement, that solves quite a few errors.
    5) Finally forgive any goof up on this reply, I have looked at source code after 12 months of hibernation post dot com doom ... so m a bit rusty... shall get better soon though :)
    warm regards and good wishes,
    Gaurav
    CW :-> Mother of all computer languages.
    I HAM ( Radio-Active )
    * OS has no significance in this error
    ** uninstalling and reinstalling ? r u nuttttttts ??? don't ever do that again unless your compiler fails to start, as long as it is giving a valid error it is working man ... all we need to do is to interpret the error and try to fix the code not the machine or compiler.

  • Problem in compiling servlet class - using Tomcat

    Hi,
    I have a servlet pgm that I'm trying to compile.I using Tomcat application server.I have my servlet class in D:\servlet_wrk\project1\src
    and my deployment descriptor in D:\servlet_wrk\project1\etc
    my CLASSPATH var is set to C:\Sun\AppServer\jdk\bin
    and
    my PATH var is set to C:\Sun\AppServer\bin.
    When I compile my servlet class Ch1Servlet.java in the command line from the directory
    D:\servlet_wrk\project1 using the command
    javac -classpath D:\applications\tomcat-5.5.12\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java,
    it says error:cannot read: src/Ch1Servlet.java
    Can somebody help me to solve this problem and help me to compile my servlet class.
    Thanks.

    Thanks...as u said I tried putting dir & found that
    my file was saved as Ch1Servlet.java.txt instead for
    Ch1Servlet.java......So that was a problem.Now I'm
    able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
    But on compiling I'm getting the following error
    package java.servlet.* does not exist
    package java.servlet.http.* does not exist
    package java.io.* does not exist
    Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation.

  • Classpath problems when importing my classes

    I'm using a tutorial with sample programs dealing with bank accounts.
    I get this error:
    InterestBearingAccount.java [9:1] '.' expected
    import Account;
    ^
    1 error
    Errors compiling InterestBearingAccount.
    The Account class already exists in the current directory. I've tried everything as far as setting the classpath variable (nothing, just a period, period & slash, the actual complete path for the current directory, nothing works!!!!!). I also tried using -classpath (.) and the end of my javac command and that seemed to not work at all.
    The Java Coffee Break tutorial have some already compiled (*.class) files and they run fine. My *.java files are identical. In fact, I cut and pasted them so I know it's not a typo.
    My path is set to include the jdk1.4.0\bin directory and I've only begun to have problems now that I need to import existing classes into the programs.
    I should mention that I get the same error using Forte environment or doing it at the command prompt window. Please help.

    Thanks ATMGUY. I commented out the import statements in both InterestBearingAccount and AccountDemo and it worked fine. I guess the author of that tutorial was obviously not working with jdk 1.4.
    As far as using packages, com.kusek.bank would make a good package name then??
    The statement:
    package com.kusek.bank; OR a shorter version package kusek.bank;
    should be added to all three classes and no import statements would then be necessary, right??
    I just remember reading that it should be something unique as a good habit to get into.
    I'm trying to learn enough to make a useful GUI program for a special project so I probably should be using packages anyway when I get to that point.
    My programming backround is limited to procredural languages Basic, QBasic, Pascal, and Fortran and I find myself still wanting to think in those terms. I have read several web sites and worked through some basic examples but I still have much to learn. I once I can grasp how to write OOP style it would be nice to look at code for a somewhat detailed application (like a store checkout app) and have every line explained as to why it's there. I can see where it makes sense to have your GUI classes predefined (Swing), File I/O, serial port communications, and even things like this InterestBearingAccount example that extends from the Account class utilizing its basic attributes but overriding the constructors for the additional parameters (interest calculation) that are passed. How to take a common problem and go about creating a solution is what I need to see being done to help me.
    My telemetry project uses VHF radios with packet radio modems to monitor two diesel engines and turn one off if the other turns off. The modems have built in A/D data gathering and can also output control signals, they just need to be told what to do. I can manually use a Windows Hyperterminal session and type in "connect Engine1" and use commands to determine the A/D inputs "analog". The modems have built in end-to-end acknowledgement so the only think I need is an application than can be setup to run in the Startup folder to handle this. It would use a timer class to "poll" engine1 every 5-10 minutes and if it has stopped (based on the response of the "analog" command) I would "disconnect" from engine1 and "connect" to engine2 and send a "ctrl B off" or something similar. The standard responses from the modem should allow me just to send and recieve STRING data to and from the serial port and parse them as needed. I need at least this much but it shouldn't be too much harder to develop a way to reset the system(reverse of this) when that is required. I could also read a water pressure value at one of the locations and display that on the screen along with the current status of the engines (using values obtained from the "analog" command on the modems).
    The hardest part of OOP programming seems to be knowing what classes are already out there and knowing how to find them or apply them. I hope Swing has classes that provide for displaying values on the Windows taskbar (my motherboard monitor freeware displays temperature readings down on the taskbar). I appreciate all the help given here. It's almost like having a private tutor.
    randy

  • Problem when compiling example from TechEd 2008

    Hi,
    I' am using sap sneak preview 7.01 and I'm trying to compile the ZMHO_EX3_*  webdynpro example.
    I get the error :
    "syntax error : long text".
    When I check the syntax I have allways the same error :
    Field ")" is unknown...
    each time the source code follow this structure :
    wd_this->mr_message_manager = wd_this->wd_get_api ( )->get_message_manager( ).
    All the attributes of the assistance class ZCL_MHO_WD_SERVICE are red highlight.
    I need to use FlashIsland to create mockups for a ramp up client, can you help me to solve this this problem ?
    Thanks,
    Regards

    Hi,
    thank you very much for answering me so quickly, I really appreciate this.
    I'have already try to fix the problem by splitting the line code, but it doesn't work.
    I paste bellow my piece of code, it is located in the method wdoinit of the component controller
    METHOD wdoinit .
    data l_api type ref to if_componentcontroller .
    l_api = wd_this->wd_get_api( ) .
    wd_this->mr_message_manager = l_api->get_message_manager( ) .
    wd_this->init_new_record( so_id = '00000000005000000010' ) .
    wd_this->read_products( ) .
    ENDMETHOD.
    I get the following error :
    The result type of the function method cannot be converted into the type of l_api type of l_api.
    Instead of if_componentcontroller I tried ig_componentcontroller too, but it doesn't work too.
    The long text error at the origin of my post as a lot of occurences in the syntax error window when I check this application: about 10 errors with the same origin.
    All attributes of the assistance class ZCL_MHO_WD_SERVICE are allways displayed in red, is it normal ?
    Have I to setup/upgrade something on my system in order it will work ?
    (There is a lot of errors, since is there a global solution to fix it in one shoot ?)
    Thank you,
    Regards.

  • Problem with compiling a class with a package

    Hello,
    I am trying to implement the package example from the SUN Tutorial. It can be found on the page: http://java.sun.com/docs/books/tutorial/java/interpack/QandE/packages-questions.html
    I think I am doing like described but it doesn�t work. The files are stored like following on my machine:
    C:\mygame\Shared\Utilities.java               (this file can be compiled)
    C:\mygame\Server\Server.java                    (can�t be compiled)
    C:\mygame\Client\Client.java                    (can�t be compiled)
    I have no CLASSPATH set (but I tried), Java is installed in C:\Java\j2sdk
    If I try to compile the file Client.java with javac the following error message occurs:
    C:\mygame\Client>javac Client.java
    Client.java:7: cannot resolve symbol
    symbol : class Utilities
    location: package shared
    import mygame.shared.Utilities;
    ^
    Client.java:23: cannot resolve symbol
    symbol : variable Utilities
    location: class mygame.client.Client
    Utilities.printMsg("creating output stream");
    ^
    Client.java:32: cannot resolve symbol
    symbol : variable Utilities
    location: class mygame.client.Client
    Utilities.printMsg("writing current date");
    ^
    3 errors
    Are there any further prerequisites?
    Thank you

    Thank you for helping me. Now I am one step forward. Now I can compile each of my Java classes. But if I want to start them with java the following messages occurs. In addition I changed all pathes and class names to lower case.
    C:\mygame\server>java server
    Exception in thread "main" java.lang.NoClassDefFoundError: server
    C:\mygame\server>cd ../client
    C:\mygame\client>java client
    Exception in thread "main" java.lang.NoClassDefFoundError: client
    C:\mygame\client>cd ../shared
    C:\mygame\shared>java utilities
    Exception in thread "main" java.lang.NoClassDefFoundError: utilities
    C:\mygame\shared>

  • Problem to compile .java class

    hi,
    i'm using/creating a package of classes....and as per my knowledge there is no need to write explicit import if u r importing/using an instance of class1 in other class2 in the same package.....
    I'm doing the same.....
    but the problem arrises here that....while compiling class2 the error occures..........
    D:\tomcat\webapps\Books\WEB-INF\classes\BookForm.java:6: cannot resolve symbol
    symbol : class Book
    location: class BookForm
         private Book book =new Book();
    why so????? as i have included the package in CLASSPATH also..........
    PLZ reply....
    .....Amita

    You don't need to import classes that are in the same package but they do need to be in the classpath. My guess is that you are compiling BookForm.java from the D:\tomcat\webapps\Books\WEB-INF\classes directory. Either add "D:\tomcat\webapps\Books\WEB-INF\classes" explicitly to your classpath or add a dot (".") to your classpath.

Maybe you are looking for