Results 1 to 12 of 12
Thread: cannot find symbol
- 01-02-2013, 06:49 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
cannot find symbol
So im following a tutorial that teaches java swing, but there is no words about compiling the thing. So im getting an error : Donut.java:11: cannot find symbol symbol : class Board location : class donut.Donut add(new Board());
Code itself is in 2 class files.andJava Code:package donut; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import javax.swing.JPanel; public class Board extends JPanel{ public void paint(Graphics g) { super.paint(g); Graphics2D g2 = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHints(rh); Dimension size = getSize(); double w = size.getWidth(); double h = size.getHeight(); Ellipse2D e = new Ellipse2D.Double(0, 0, 80, 130); g2.setStroke(new BasicStroke(1)); g2.setColor(Color.gray); for (double deg = 0; deg < 360; deg += 5) { AffineTransform at = AffineTransform.getTranslateInstance(w / 2, h / 2); at.rotate(Math.toRadians(deg)); g2.draw(at.createTransformedShape(e)); } } }
How to fix this problemJava Code:package donut; import javax.swing.JFrame; public class Donut extends JFrame { public Donut() { add(new Board()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(360, 310); setLocationRelativeTo(null); setTitle("Donut"); setVisible(true); } public static void main(String[] args) { new Donut(); } }
- 01-02-2013, 07:18 PM #2
Re: cannot find symbol
How is your directory structure set up? How are you compiling this?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-02-2013, 08:10 PM #3
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
Re: cannot find symbol
They both are at the same folder. and im using the javac command in cmd to compile it. javac *.java.
and im also getting could not find or load main class Donut.class
- 01-02-2013, 08:25 PM #4
Re: cannot find symbol
Moved from a staff-only section.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-02-2013, 08:26 PM #5
Re: cannot find symbol
Swing isn't a starting point for learning Java. Start here: The Java™ Tutorials
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-02-2013, 09:50 PM #6
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
Re: cannot find symbol
Main problem i have with java is the compiling side. I have studied c++ for a few years, so i get the basics of java, few commands here and there and a different outlook but inside its similar. Compiler for c++ are so much more user friendly than the java compiler. I had a lot of trouble to get the javac even working. So my guess is that i either have something somewhere wrong or the 2 files just dont see eachother.
- 01-03-2013, 02:48 PM #7
Member
- Join Date
- Jan 2013
- Posts
- 30
- Rep Power
- 0
Re: cannot find symbol
I used java bit wrong at first. after i used javac *.class it started working.
- 01-03-2013, 03:04 PM #8
Re: cannot find symbol
That doesn't seem right. You should use javac to compile your .java files, which creates .class files. You then use the java command to run one of the .class files. I'd suggest copying and pasting exactly what you're doing from the command prompt, as it seems like you're doing something strange.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-03-2013, 06:55 PM #9
Member
- Join Date
- Dec 2012
- Posts
- 42
- Rep Power
- 0
Re: cannot find symbol
are you using command prompt for a specific reason? i know some people prefer it but possibly a java IDE like Eclipse or netbeans might be helpfull in this situation? then your compile and run is just a click and you can spend more time focusing on learning java and less time on learning command propts. unless of course your using an OS that is command based
- 01-03-2013, 07:11 PM #10
Re: cannot find symbol
I'm going to go ahead and disagree here. It is precisely due to misunderstanding the basics such as the difference between a .java file and a .class file that novices should stick with the command prompt, at least for the first few weeks. An IDE might hide that from you, but that doesn't make the problem go away.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-04-2013, 08:42 AM #11
Member
- Join Date
- Dec 2012
- Posts
- 74
- Rep Power
- 0
Re: cannot find symbol
I second the motion to use a decent IDE such as Eclipse. Using Eclipse, i got the code to work in short order. I do know how to use the command line. I had to use the command line for a whole Java course. I'm just glad that now I can use Eclipse.
Eclipse Download:
Eclipse IDE for Java Developers | Eclipse Packages
- 01-04-2013, 11:11 AM #12
Similar Threads
-
Cannot find symbol
By sam.jj12 in forum AWT / SwingReplies: 2Last Post: 09-16-2012, 01:27 PM -
Cannot find Symbol
By webbby in forum New To JavaReplies: 3Last Post: 04-14-2011, 12:51 AM -
Cannot find symbol
By shane5317 in forum AWT / SwingReplies: 3Last Post: 03-02-2011, 11:36 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks