• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch
Please provide more details. We can't understand the problem from the little information you have provided.
 
Jiken Jarecha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
File attachment here..
Filename: untitled.bmp
File size: 677 Kbytes
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jiken Jarecha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
after you updated your classpath, did you open a new command window? One that is already open will not pick up your changes.
 
Jiken Jarecha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
\/

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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To execute it use
java ShirtTest

and not javac ShirtTest

 
Jiken Jarecha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic