Results 1 to 6 of 6
Thread: Some questions about packages.
- 04-02-2011, 03:10 PM #1
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Some questions about packages.
I am working on a text editor and it's starting to become a decent amount of files and I would like to organize them better.
So far I have a source file which is the actual text editor, which handles all saving and font changing. The file uses actions which I would like to store in a folder.
For example I have
there are 12 action classes in total. I would like to store them in a path ofJava Code:public class SaveAction extends AbstractAction{} public class OpenAction extends AbstractAction()
I packaged them all like thisJava Code:c:/javacode/texteditor/actions
I would have the actual text editor in the the path ofJava Code:package texteditor.actions;
and packaged withJava Code:c:/javacode/texteditor
My classpath points to the javacode directory.Java Code:package texteditor;
Here is where I am running into trouble. All the actions have an instance of a text editor and the text editor has an instance of the actions. When I try to compile any of the code I get errors for all the instances of the other class. When compiling the actions I get errors for the text editor references, when compiling the texteditor I get errors for every reference to any action.
It seems like it's a circular problem where each file relies on the other being already compiled.
Any way to do this? I hope I am making myself clear.
Finally, if I can compile the code, does it matter where the class files need to be stored? Or can they be anywhere that the classpath can get access to?
Thanks for any help guys.
- 04-02-2011, 04:15 PM #2
- 04-02-2011, 04:35 PM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Thanks for that. As for my other question, here is an example of what I am having trouble with.
This is in the directory
Java Code:c:/javacode/test
and then b is in the directoryJava Code:package test; import test.package1.*; public class A{ private B x = new B(this); }
Java Code:c:/javacode/test/package1
errors when attempting to compile AJava Code:package test.package1; import test.*; public class B{ private A x; public B(A x){ this.x = x; } }
When I compile bJava Code:a.java:3: package test.package1 does not exist import test.package1.*; ^ a.java:6: cannot find symbol symbol : class B location: class test.A private B x = new B(this); ^ a.java:6: cannot find symbol symbol : class B location: class test.A private B x = new B(this); ^ 3 errors
Java Code:C:\Javacode\Test\Package1>javac b.java b.java:6: cannot find symbol symbol : class A location: class test.package1.B private A x; ^ b.java:7: cannot find symbol symbol : class A location: class test.package1.B public B(A x){ ^ 2 errors
-
- 04-02-2011, 04:50 PM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Wow, I love you Fubar, when I read online it said to make package names lowercase so I assumed, and clearly made an ass of myself. Thanks very much for the help you guys.
-
Similar Threads
-
packages
By fogus in forum New To JavaReplies: 1Last Post: 03-24-2009, 06:14 AM -
Importing packages from the packages within same application.
By sta2003 in forum New To JavaReplies: 3Last Post: 02-12-2008, 11:03 AM -
Using packages
By prfalco in forum New To JavaReplies: 5Last Post: 01-31-2008, 10:38 PM -
packages
By ai_2007 in forum Advanced JavaReplies: 1Last Post: 07-31-2007, 12:10 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks