Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Compiling Errors

arnshcharnshch Member Posts: 12
I've code a small program, but when tried to compile it
received 6 errors of the same type: "cannot resolve symbol
:class Welcome
:location class divelog.DiveLog
new Welcome()"
for all the 6 calls to constructors
like Welcome(), shown in the excerpt
from the code below.
The rest of the code up to this point(and this is, approximately,
the middle of it) shows no errors.
Now, all the 6 public classes(shown in error) are part of the same package
as the program's class itself.
What could be the cause of the problem?


private void populateTabbedPane()
{
tabbedPane.addTab(
"Welcome",
null,
new Welcome(),
"Welcome to the Log");

.....................
}

Comments

  • nightsurfernightsurfer Member Posts: 272
    That looks like you are missing a class declaration. Your program is trying to create an object of type Welcome, but cannot find the class file for it. Either you haven't created and compiled it yet (it may be in another file which has a name other than Welcome.java) or it's in a location that can't be accessed from this class file. If you have already created and compiled it, and it resides in the same directory as your program, then make sure you included ".;" in your classpath definition in the autoexec.bat file (found in the main directory of your harddrive).

    Hope this helps.


    : I've code a small program, but when tried to compile it
    : received 6 errors of the same type: "cannot resolve symbol
    : :class Welcome
    : :location class divelog.DiveLog
    : new Welcome()"
    : for all the 6 calls to constructors
    : like Welcome(), shown in the excerpt
    : from the code below.
    : The rest of the code up to this point(and this is, approximately,
    : the middle of it) shows no errors.
    : Now, all the 6 public classes(shown in error) are part of the same package
    : as the program's class itself.
    : What could be the cause of the problem?
    :
    :
    : private void populateTabbedPane()
    : {
    : tabbedPane.addTab(
    : "Welcome",
    : null,
    : new Welcome(),
    : "Welcome to the Log");
    :
    : .....................
    : }
    :

    There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.

  • arnshcharnshch Member Posts: 12
    [b][red]This message was edited by arnshch at 2002-9-25 9:29:51[/red][/b][hr]

    I specifically included this sentence to preclude the notion of
    those classes missing.
    The second suggestion of yours was likely to be the resolution
    of my problem, but, there is no way I could find
    autoexec.bat file on C: drive(the only harddrive I got).
    So I opted for command: set classpath=.;C:oracleora92jdkin.(I missed the equal sign first time I sent to you.)
    It didn't help either, though the command did set the classpath
    to the desired path(I checked it.)
    What did help is the inclusion of those 6 class definitions
    into the program's file. So it looks like javac doesn't look
    into the directory the main and other java files are in, just into the program which name is specified in the javac command, despite of the package statement included into every one of those files?!
    Anyway, I got it compiled, but facing another problem now.
    When I tried to execute the compiled program, I got the following
    error: exception in thread "main" java.lang.NoClassDefFoundError:
    path-to-the-program-file.
    All I got in main() is one line:
    DiveLog dl = new DiveLog();
    /* the name of the program is DiveLog with
    the coded(not default) constructor public DiveLog(). */
    So what the hell this could be?
    --------------------------------------------------------------------
    : That looks like you are missing a class declaration. Your program is trying to create an object of type Welcome, but cannot find the class file for it. Either you haven't created and compiled it yet (it may be in another file which has a name other than Welcome.java) or it's in a location that can't be accessed from this class file. If you have already created and compiled it, and it resides in the same directory as your program, then make sure you included ".;" in your classpath definition in the autoexec.bat file (found in the main directory of your harddrive).
    :
    : Hope this helps.
    :
    :
    : : I've code a small program, but when tried to compile it
    : : received 6 errors of the same type: "cannot resolve symbol
    : : :class Welcome
    : : :location class divelog.DiveLog
    : : new Welcome()"
    : : for all the 6 calls to constructors
    : : like Welcome(), shown in the excerpt
    : : from the code below.
    : : The rest of the code up to this point(and this is, approximately,
    : : the middle of it) shows no errors.
    : : Now, all the 6 public classes(shown in error) are part of the same package
    : : as the program's class itself.
    : : What could be the cause of the problem?
    : :
    : :
    : : private void populateTabbedPane()
    : : {
    : : tabbedPane.addTab(
    : : "Welcome",
    : : null,
    : : new Welcome(),
    : : "Welcome to the Log");
    : :
    : : .....................
    : : }
    : :
    :
    : There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.
    :
    :



  • nightsurfernightsurfer Member Posts: 272
    : When I tried to execute the compiled program, I got the following
    : error: exception in thread "main" java.lang.NoClassDefFoundError:
    : path-to-the-program-file.
    : All I got in main() is one line:
    : DiveLog dl = new DiveLog();
    : /* the name of the program is DiveLog with
    : the coded(not default) constructor public DiveLog(). */
    : So what the hell this could be?
    : --------------------------------------------------------------------

    Hi,
    I would check to see that your file names are correct. javac does not care what you call your compiled files, but java does. So when you run the program, if the name of the file is not exactly the same as the name of the class as defined in the source file, you will get the error shown above.

    About finding the autoexec.bat file, just search for it using your OS search command (in windows, under the start menu, find) and then open it from there. Since you already have your path defined, you must have an autoexec file to do that for you at startup, and you should be able to modify it. After you modify it, don't forget to type autoexec.bat into the command terminal (DOS window, UNIX command prompt) or to restart your computer.


    There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.

  • arnshcharnshch Member Posts: 12
    : : When I tried to execute the compiled program, I got the following
    : : error: exception in thread "main" java.lang.NoClassDefFoundError:
    : : path-to-the-program-file.
    : : All I got in main() is one line:
    : : DiveLog dl = new DiveLog();
    : : /* the name of the program is DiveLog with
    : : the coded(not default) constructor public DiveLog(). */
    : : So what the hell this could be?
    : : --------------------------------------------------------------------
    :
    : Hi,
    : I would check to see that your file names are correct. javac does not care what you call your compiled files, but java does. So when you run the program, if the name of the file is not exactly the same as the name of the class as defined in the source file, you will get the error shown above.
    :
    : About finding the autoexec.bat file, just search for it using your OS search command (in windows, under the start menu, find) and then open it from there. Since you already have your path defined, you must have an autoexec file to do that for you at startup, and you should be able to modify it. After you modify it, don't forget to type autoexec.bat into the command terminal (DOS window, UNIX command prompt) or to restart your computer.
    :
    :
    : There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.
    :
    :

    Thanks alot for following up.
    The names' mismatch, was obviously the first thing I checked,
    and that wasn't it; I wouldn't bother anybody otherwise.
    What I did since then was that I compiled another very small program
    that certainly worked on my old computer with JDK on it,
    just to check if any java class file can be executed within my current setup. It failed with the exactly same error, as in the first case.
    As far as the search for autoexec.bat is concerned I did look for it
    using Find feature of Windows XP Professional OS installed on my
    machine and it was unable to locate any. So, as I indicated earlier,
    I just used SET command to get the same result as I would do using
    edit. Still the problem remains unsolved: Why javac works, but java
    doesn't for the files located in the same directory?

  • nightsurfernightsurfer Member Posts: 272
    did you set both the path and the classpath properly?


    There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.

  • arnshcharnshch Member Posts: 12

    : did you set both the path and the classpath properly?
    :
    :
    : There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.
    :
    :

    Yes, I did.
  • arnshcharnshch Member Posts: 12
    : did you set both the path and the classpath properly?
    :
    :
    : There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.
    :
    :

    I'm just guessing here, but could the cause of the problems
    I experiencing with 'javac' and 'java' be the apparent absence
    of JVM on Windows XP? Every time the machine has to run some
    Java applet from any of the Internet sites it tells me it missing the one and asks me if I would like to download JVM. (But then it refuses to do so directly, as damned Microsoft discontinued its support for Java, though it tells you the way around it.) So, I'm kind of confused here: Shouldn't that JVM be
    copied while copying Oracle DB 9.2 and Server, which did copy JDK 1.3 with it?
  • Andre YoungAndre Young USAMember Posts: 0

    _____ [ http://forcoder.org ] free ebooks and video tutorials about | Perl, Swift, R, Visual Basic .NET, MATLAB, JavaScript, PHP, Assembly, PL/SQL, Python, C#, Java, Scratch, Go, Visual Basic, C++, C, Objective-C, Delphi, Ruby ML, LabVIEW, Julia, Lisp, Logo, D, Ada, Apex, Scala, Bash, FoxPro, Awk, Alice, Fortran, Crystal, SAS, Clojure, Transact-SQL, ABAP, VBScript, Lua, Hack, Kotlin, Dart, COBOL, Rust, F#, Prolog, Erlang, Scheme | _____

Sign In or Register to comment.