aspose file tools*
The moose likes Beginning Java and the fly likes Symbol7 for Class error -- no package used just normal class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Symbol7 for Class error -- no package used just normal class " Watch "Symbol7 for Class error -- no package used just normal class " New topic
Author

Symbol7 for Class error -- no package used just normal class

Jiken Jarecha
Greenhorn

Joined: Feb 17, 2009
Posts: 9
I am novice user of JAVA

Created 2 Class

Shirt.java
ShirtTest.java

in C:\labs folder

Then tried to compile Shirt.java compiled perfect

ShirtTest.java give me Symbol7 for Class

set up environment variables

checked for import

but can not solve error.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36486
    
  16
Welcome to JavaRanch
Please provide more details. We can't understand the problem from the little information you have provided.
Jiken Jarecha
Greenhorn

Joined: Feb 17, 2009
Posts: 9
Installed JDK C:\Program Files\Java\jdk1.6.0_12

Set Environment Variables

As exercise I created 2 classes in given directory

C:\Program Files\Java\jdk1.6.0_12\bin\Labs\SL110\exercises\getstarted

Shirt.java
=====================================
public class Shirt {

public int shirtID = 0; // Default ID for the shirt
public String description = "-description required-"; // default

// The color codes are R=Red, B=Blue, G=Green, U=Unset

public char colorCode = 'U';

public double price = 0.0; // Default price for all shirts

public int quantityInStock = 0; // Default quantity for all shirts

// This method displays the values for an item

public void displayShirtInformation() {

System.out.println("Shirt ID: " + shirtID);
System.out.println("Shirt description:" + description);
System.out.println("Color Code: " + colorCode);
System.out.println("Shirt price: " + price);
System.out.println("Quantity in stock: " + quantityInStock);
} // end of display method
} // end of class



Other class where my main is

ShirtTest.java

import java.Shirt.*;

public class ShirtTest {
public static void main (String args[]) {

Shirt myShirt;
myShirt = new Shirt();

myShirt.displayShirtInformation();
}
}


Now, from CMD prompt try to run both classes

running Shirt.java compile fine and perfect no errors and create Shirt.class

after that compiling ShirtTest.java which give me errors as given below:

ShirtTest.java:4: cannot resolve symbol
symbol : class Shirt
location: class ShirtTest
Shirt myShirt;
^

ShirtTest.java:5: cannot resolve symbol
symbol : class Shirt
location: class ShirtTest
myShirt = new Shirt();
^

Attaching Screeshot for more details

Also, I tried all possible solutions in FAQ, google as well other forums

and this is part of sun training program fundamentals one.



Jiken Jarecha
Greenhorn

Joined: Feb 17, 2009
Posts: 9
File attachment here..


[Download untitled.bmp] Download

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

cd C:\Program Files\Java\jdk1.6.0_12\bin\Labs\SL110\exercises\getstarted
javac -cp . ShirtTest.java

That's "javac space dash cp space dot space ShirtTest.java" .

The problem is that your CLASSPATH environment variable should be not set to anything, but you have it set to something, and that something doesn't include "." (dot), which stands for the current directory, whatever it is.


[Jess in Action][AskingGoodQuestions]
Jiken Jarecha
Greenhorn

Joined: Feb 17, 2009
Posts: 9
Tried given and it give me given message

C:\Program Files\Java\jdk1.6.0_12\bin\Labs\SL110\exercises\getstarted>javac -cp
. ShirtTest.java
javac: invalid flag: -cp
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are us
ed
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options


C:\Program Files\Java\jdk1.6.0_12\bin\Labs\SL110\exercises\getstarted>


After that also updated CLASSPATH in environment variables but same behavior please advice, appreciate your reply Ernest Friedman & Campbell Ritchie..
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

after you updated your classpath, did you open a new command window? One that is already open will not pick up your changes.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jiken Jarecha
Greenhorn

Joined: Feb 17, 2009
Posts: 9
\/

SUCCESS !!

also when I execute ShirtTest

i.e. C:.. > javac ShirtTest

It give me classnotfoundexception so I replaced command with javac -cp . ShirtTest

but I wonder why to use -cp everytime if someone can explain ..

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36486
    
  16
The problem is that, having set up a classpath, you have prevented the java tool from finding the classes is ought to execute.

If you set up the classpath variable yourself, delete it altogether, and see what happens.
If you didn't set it up yourself, edit it to include . for current directory. It can start with .; or end with ;. or have ;.; in the middle, assuming you are using DOS/Windows.

Don't put your work in Program Files; when you open your command prompt write

mkdir java


(or similar) then you can write

cd java

whenever you open a command prompt, and go to wherever your Java work it. That Java folder will be somwhere in documents and settings, where you ought to keep your work.
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
To execute it use
java ShirtTest

and not javac ShirtTest

Jiken Jarecha
Greenhorn

Joined: Feb 17, 2009
Posts: 9
Thanks Campbell .. understood conceptually

Sri I use java for execution

Working on Sun Trainings .. started with fundamentals

are there any people who doing same?

Also my learning path is

Sun trainings then K&B books targeting SCJP exam

any inputs ? how long it should take considering 3 hours a day avg
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Symbol7 for Class error -- no package used just normal class
 
Similar Threads
Doubt in inner class
Deploying Multiple ejb.jar files
jsp:usebean
Collections
Weblogic deployement of a webservice