Results 1 to 6 of 6
- 07-24-2009, 01:37 PM #1
Member
- Join Date
- Jul 2009
- Posts
- 2
- Rep Power
- 0
I got an error message when using package in Textpad
I have two classes in same package: class A and class B. B will used an object of class A. Then I compile it. Instead of success, I got error message like this: "package namePackage does not exist"
Fyi, I placed both A and B in same folder. Therefore, A.class and B.class were in same directory.
I tried removing package command from both javas and there is no error message. Did anyone ever encounter something like this? Or Textpad couldn't solve problem like this?Last edited by magicianseeker; 07-24-2009 at 01:41 PM. Reason: mistype
- 07-24-2009, 02:39 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
- 07-24-2009, 04:56 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 2
- Rep Power
- 0
Yes, the directory (the folder where I put both classes) is namePackage (the name of directory = namePackage).
Er, how do I know if Textpad treated the directory above namePackage as source directory or not? And why do it need to do so? Can the source (main class) be also in the package?
Actually, it is like this:
My current directory now is E:\Java-Source\namePackage. Both of A.class and B.class are in namePackage. Main class is in B.class. So basically I called a class within same package in the same directory. Could it be done?Last edited by magicianseeker; 07-27-2009 at 03:57 AM. Reason: add details
- 07-28-2009, 03:15 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
As I say, I don't know how textpad works, but for compiling you would point java at a source directory, which in your case would be Java-Source. It would then know that classes (.java files) in package namePackage would be found in the directory namePackage.
Now, if you have textpad (somehow) thinking that namePackage is the source directory then it would give you the error you're getting.
Other options are that the directory and package names don't match, of course. Ie, there's a typo somewhere.
- 07-28-2009, 06:18 PM #5
Member
- Join Date
- Jul 2009
- Posts
- 35
- Rep Power
- 0
Sounds like you aren't compiling correctly?
if you had say
/folder/name/A.java
/folder/name/B.java
Then to compile you would go down a directory to "folder" and doJava Code:package name; public class A { ... } package name; public class B { ... }
javac ./name/*.java
And to run
java name.A
Anyway if it works without the packages it means you either didn't put them both in the same folder, didn't put package declarations in both, didn't compile them both correctly or didn't run them correctly.
Go here for info on packages: java.sun.com/docs/books/tutorial/java/package/packages.html (cant link :/)
- 12-09-2010, 03:57 AM #6
Member
- Join Date
- Dec 2010
- Location
- Corona, CA
- Posts
- 1
- Rep Power
- 0
TextPad may not support Packages
Some java tools aren't able to compile classes that have been organized into packages. For example, once you store a Class in (ExampleDirectory.ExampleBusinessPackage) you cant use TextPad to compile the Classes that are in that package because Your Classes depends on some classes that you imported into that class. Try using the command prompt to compile your classes in the package. To do that>>>>>.. here are the steps.
1. Open your command prompt in windows.
2. once youre in the command prompt. go to the root directory of your packages.
3. here is the syntax: Ex:
C:\java\ lineItem>javac king/business/LineItem.java
//notice: this is just an example, it depends on you where you saved your package.
this is what you call the"javac command".
if Im wrong, please give me some more info. I'd like to be schooled.
String p = "peace";
String o = "Out";
System.out.println( "Hope this solves your problem \n" +p+o);
Similar Threads
-
Same error msg with every program Java Textpad
By peterdfl in forum New To JavaReplies: 7Last Post: 04-17-2009, 04:49 AM -
Compiles in Netbeans, error in textpad
By Npcomplete in forum New To JavaReplies: 2Last Post: 11-21-2008, 04:50 AM -
Error Message in JBuilder
By RavenNevarmore in forum New To JavaReplies: 4Last Post: 10-08-2008, 06:53 AM -
strange Error message
By little_polarbear in forum New To JavaReplies: 4Last Post: 08-25-2008, 11:45 PM -
error message on jsp
By sandor in forum Web FrameworksReplies: 1Last Post: 04-11-2007, 02:10 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks