hey guys, i am a newbie in java. While compiling this code(which i wrote to test whether swing's JFrame was working or not so as to add more components) I encountered an error:
Here's the code:
Test class code
MarkAnalysis class code
The error message was :
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Mohan>javac Test.java
Test.java:5: cannot find symbol
symbol : class MarkAnalysis
location: class Test
MarkAnalysis marks = new MarkAnalysis() ;
^
Test.java:5: cannot find symbol
symbol : class MarkAnalysis
location: class Test
MarkAnalysis marks = new MarkAnalysis() ;
^
2 errors
C:\Documents and Settings\Mohan>
Please help me. I am using Windows XP.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35224
7
posted
0
Try compiling both in one go: "javac *.java". That will compile all Java files in the current directory.
Prabhakar Bokka wrote:This is definitely a classpath issue.
How do you know? It might not be.
Are both those classes in the same folder? What happens when you write "javac MarkAnalysis.java"? And you cannot import a class without a package name, but forget all about package names and imports at this stage.
Hari Mohanan
Greenhorn
Joined: Jun 30, 2010
Posts: 8
posted
0
The files are in the same folder. I have tried this before while i was coding a calculator program. There was no problem then. The only change I made was install the newer version of java sdk.
Ulf Dittmer wrote:Try compiling both in one go: "javac *.java". That will compile all Java files in the current directory.
It worked: i compiled it together
But the trouble is at execution time now----
C:\Documents and Settings\Mohan>java Test.class
Exception in thread "main" java.lang.NoClassDefFoundError: Test/class
Caused by: java.lang.ClassNotFoundException: Test.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Test.class. Program will exit.