Cannot Resolve Symbol when compiling

I have created a very small class in a directoy called c:\hottub as follows:

package hottub;

import java.awt.*;

import java.awt.event.*;

public class GenInfo

{

public GenInfo()

{

}

}

A class is created call GenInfo.class no problem.

My classpath is:

c:\java\steve;C:\java\bin

But I am compiling like this:

c:|hottub>javac -classpath c:\ GenInfo.java

Here is where the trouble begins:

I have tried this many ways. No matter what I try, I get the same result. Here is the code:

package hottub;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class HotTub

{ // open the class

private JTabbedPane tabPane;

private JFrame sframe;

// -> Constructor HotTub Starts <

public HotTub()

{ // open constructor

sframe = new JFrame("Safronuk System");

sframe.addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{ System.exit(0); }

});

tabPane = new JTabbedPane(SwingConstants.LEFT);

tabPane.setBackground(Color.blue);

tabPane.setForeground(Color.white);

loadTabPane();

} // close constructor

// -> loadTabPane method <

private void loadTabPane()

{ // open method

tabPane.addTab("General", new GenInfo());

} // close method

// -> Mainline <

public static void main(String[] args)

{

HotTub ht = new HotTub();

}

} // close the class

In the loadTabPane method, just above Mainline, I keep getting Cannot Resolve Symbol with the arrow under GenInfo(). It was compiled many ways but here is one of them:

c:\hottub>javac -classpath c:\ HotTub.java

I have even tried putting all the code in the Steve directory and the same error occurs even when compiling by:

c:\java\steve>javac GenInfo.java

c:\java\steve>javac HotTub.java

In all cases GenInfo compiles and HotTub does not. Can somebody help me? I've been working on this for over a week.

[2169 byte] By [ssaf] at [2007-9-26 20:30:39]
# 1

> I have created a very small class in a directoy called

> c:\hottub as follows:

>

> package hottub;

> import java.awt.*;

> import java.awt.event.*;

> public class GenInfo

> {

> public GenInfo()

> {

> }

> }

>

>

> A class is created call GenInfo.class no problem.

> My classpath is:

>

> c:\java\steve;C:\java\bin

>

> But I am compiling like this:

> c:|hottub>javac -classpath c:\ GenInfo.java

>

> Here is where the trouble begins:

> I have tried this many ways. No matter what I try, I

> get the same result. Here is the code:

>

> package hottub;

>

> import javax.swing.*;

> import java.awt.*;

> import java.awt.event.*;

>

> public class HotTub

> { // open the class

>

> private JTabbedPane tabPane;

> private JFrame sframe;

>

> // -> Constructor HotTub Starts

> ts <

> public HotTub()

> { // open constructor

> sframe = new JFrame("Safronuk System");

>

> sframe.addWindowListener(new WindowAdapter()

> { public void windowClosing(WindowEvent e)

> { System.exit(0); }

> });

>

> tabPane = new JTabbedPane(SwingConstants.LEFT);

> tabPane.setBackground(Color.blue);

> tabPane.setForeground(Color.white);

>

> loadTabPane();

>

> } // close constructor

>

>

> // -> loadTabPane method <

> private void loadTabPane()

> { // open method

> tabPane.addTab("General", new GenInfo());

>

> } // close method

>

>

> // -> Mainline <

> public static void main(String[] args)

> {

> HotTub ht = new HotTub();

> }

>

> } // close the class

>

>

> In the loadTabPane method, just above Mainline, I keep

> getting Cannot Resolve Symbol with the arrow under

> GenInfo(). It was compiled many ways but here is one

> of them:

>

> c:\hottub>javac -classpath c:\ HotTub.java

>

> I have even tried putting all the code in the Steve

> directory and the same error occurs even when

> compiling by:

>

> c:\java\steve>javac GenInfo.java

> c:\java\steve>javac HotTub.java

>

> In all cases GenInfo compiles and HotTub does not.

> Can somebody help me? I've been working on this for

> over a week.

Make sure that <your_java_files>.class files are available in the classpath, not the .java files.

e.g: set classpath =%classpath%; c:\java\steve\HotTub.class;

Hope it solves.

/Sreenivasa Kumar Majji

skmajji at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...
# 2
Same error occurs. Anyone else want to give it a try?
ssaf at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...
# 3

> Same error occurs. Anyone else want to give it a try?

compile your classes (which have package statement) with -d option.

e.g: javac -d . <your_java_source_file>

It will create a directory with the package name, under currnet directory. Include the .class files (with the newly created directory structure) in the CLASSPATH as mentioned in the previous file and execute your Java programs.

/Sreenivasa Kumar Majji.

skmajji at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...
# 4

thanks for the info. But the problem is still on the compile. I don't know if I made this clear enough. The first class created is GenInfo.class in the hottub directory. Lets forget about the path for now. It is the first set of code. Compiles clean.

The second .java source is the one called HotTub.java that cannot find the class GenInfo during its compile. I am under the assumption when I use the

package hottub;

I have access to use the classes within this newly created package as well as add to this package. For this example if we start from the beginning by using a new library

c:\hottub

I should be able to compile like:

c:\hottub>javac -classpath c:\ GenInfo.java

and the class is created.

c:\hottub>javac -classpath c:\ HotTub.java

ends up with the error Cannot Resolve Symbol indicating the GenInfo.class. But the class does exist in this directory because it was just created.

The previous suggestion still did not resolve the problem. The funny thing about this is in the examples or tutorials for the DiveLog, this worked fine. Compiled the same way but I did copy the source code from the Sun site. Even now when I compile the DiveLog example in this way, it works. I don't see a difference. More help required!

ssaf at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...
# 5

> thanks for the info. But the problem is still on the

> compile. I don't know if I made this clear enough.

> The first class created is GenInfo.class in the

> hottub directory. Lets forget about the path for

> now. It is the first set of code. Compiles clean.

>

> The second .java source is the one called HotTub.java

> that cannot find the class GenInfo during its compile.

> I am under the assumption when I use the

> package hottub;

> I have access to use the classes within this newly

> created package as well as add to this package. For

> this example if we start from the beginning by using a

> new library

> c:\hottub

> I should be able to compile like:

> c:\hottub>javac -classpath c:\ GenInfo.java

> and the class is created.

Here it's taking classpath as nothing, basically GenInfo.java doesn't require any user defined classes.

Compile this class with the following option

javac -d . GenInfo.java

( i recommend copy and paste the above command)

Assume that it's under c:\java\steve.

After execution of the above command, you will see

a directory and class.

Directory : c:\java\steve\hottub

Class : c:\java\steve\hottub\GenInfo.class

Now include set the classpath as follows

set classpath=%classpath%;c:\java\steve\hottub\GenInfo.class; .;

Now compile the HotTub.java

If you still getting the same problem, send me an e-mail at skmajji@yahoo.com

/Sreenivasa Kumar Majji.

> c:\hottub>javac -classpath c:\ HotTub.java

?

> ends up with the error Cannot Resolve Symbol

> indicating the GenInfo.class. But the class does

> exist in this directory because it was just created.

>

> The previous suggestion still did not resolve the

> problem. The funny thing about this is in the

> examples or tutorials for the DiveLog, this worked

> fine. Compiled the same way but I did copy the source

> code from the Sun site. Even now when I compile the

> DiveLog example in this way, it works. I don't see a

> difference. More help required!

skmajji at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...
# 6

You won't believe how stupid I was! Originally I wanted to use the classpath and realized for this application when put on another machine I may run into some grief due to my lack of PC knowlege. Midrange knowledge no problem but PC is a little different. Since I decided to use c:\Hottub as my directory all my .java and .class files were created. My package was called hottub. Notice the case for the H. That appeared to be my problem for the whole thing. I will try your suggestion to make sure I understand what is actually going on and setting up my classpath correctly. I will let you know. Thanks for the help.

ssaf at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...
# 7
What's funny is JAVAC does not like it but JDev will compile and exec it with no compilation errors. What's up with that?
kim77751 at 2007-7-3 18:56:48 > top of Java-index,Developer Tools,Java Compiler...