This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Error In the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error In the code" Watch "Error In the code" New topic
Author

Error In the code

shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226



can anybody help me in resolving the error in the bold lines??

AFter compilation "an not found class of these bold lines"
Between lines 14 to 17..
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2398
    
  50
Each of those lines constructs an object and adds it to the tabbed pane. The compiler can't find any of those classes so where are the Sharp, Blurr, Edge etc classes?
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

hii Tony

These classes are in the same folder where this Main.java exist..
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2398
    
  50
Have you tried compiling one of those classes eg Sharp.java?
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

Yeah,, but they are also not compiling...



here line 66, 71, 76 and 81 have errors .. can't rechognise Main..
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

How are you compiling? Do you use javac from a command line, or use a build tool like Ant or Maven, or use an IDE like IntelliJ or Eclipse. The trick is going to be compiling all source files in the package at once so the compiler can resolve all the cross-references you have. You might also consider refactoring to reduce the cross-references. This could make the program easier to work with in a number of ways.
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

I have compiled my programm using Javac key word in cmd..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14422
    
  23

What is the exact command that you are typing to compile the source code? And what exactly is the output? (Please copy & paste the command and the output from the compiler).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
[pedantic mode]It is not Javac, but javac. And it is not a keyword. It is a program name.[/pedantic mode]
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

yeah i am soory,, it was a typing mistake .. happens in the foram post only..
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

Try "javac *.java" instead of "javac Sharp.java". Keep any other compile flags you may be using the same.
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

To Jesper de Jong
Here is the copy of cmd where i am trying to run Main.java ..


Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\SINGHALS>cd desktop

C:\Users\SINGHALS\Desktop>cd ImageProject

C:\Users\SINGHALS\Desktop\ImageProject>cd ImageProject

C:\Users\SINGHALS\Desktop\ImageProject\ImageProject>javac Main.java
Main.java:14: cannot find symbol
symbol : class Sharp
location: class Main
tabs.addTab("Sharp",new Sharp());
^
Main.java:15: cannot find symbol
symbol : class Blurr
location: class Main
tabs.addTab("Blurr",new Blurr());
^
Main.java:16: cannot find symbol
symbol : class Edge
location: class Main
tabs.addTab("Edge",new Edge());
^
Main.java:17: cannot find symbol
symbol : class AntiAlias
location: class Main
tabs.addTab("AntiAlias",new AntiAlias());
^
Main.java:18: cannot find symbol
symbol : class Epipolar
location: class Main
tabs.addTab("Epipolar",new Epipolar());
^
Main.java:19: cannot find symbol
symbol : class DGFilter
location: class Main
tabs.addTab("Direction Gaussian Filtering",new DGFilter());
^
6 errors

C:\Users\SINGHALS\Desktop\ImageProject\ImageProject>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Which folder are those .java files in? Which folder are you trying to compile from?
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

All of these files reside in "C:\Users\SINGHALS\Desktop\ImageProject\ImageProject" folder..
and i am trying to compile them in the same folder..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
And none has a package declaration?
I tried your two classes, had to remove the bold tags (don’t put any other tags inside code tags; they don’t work), commented out the addition of Blurr (it should be Blur) etc., and it both compiled and ran for me.
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

Nope none has Package decleration

After changing the blurr --> blur
Still unable to compile the Main.java file..
got the same 6 errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
When I commented out the lines with the classes in which you didn’t supply (Blur, Edge, etc), I was able to compile and run it. Where are the Blur, Edge, etc, .java and .class files?
Roshan Wankhade
Greenhorn

Joined: Dec 07, 2011
Posts: 21

Hi Friend,
I think you should compile all the source file at once by following command

javac file1.java file2.java
or using
javac *.java

then run Main Class



Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Please share the source of the dependent files ( Blurr, AntiAlias, EpiPolar) which the compiler is unable to resolve.


~ Mansukh
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2398
    
  50
No don't post the rest of the files they are not necessary.

You've probably set the CLASSPATH env variable and not included the current directory. Try the following
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

Yeah Toni..
Thanks finally compiled..

That is My Environment variables are not perfect..
Thanks
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2398
    
  50
Thanks finally compiled..

My pleasure

That is My Environment variables are not perfect..

Looks that way. I suggest you append a ";." to the CLASSPATH environment variable value.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error In the code