Results 1 to 11 of 11
  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Cool package src.Verbs clashes with class of same name

    Woot woot?
    I dont get it!
    I got alot of packages inside the folder Verbs.
    And when I make em packages i say:
    package src.Verbs;
    Now I got no script names verbs or anything in the folder named src with the name Verbs.
    Still I get this error! Why?

    Heres my script, they all look kinda like this:
    PHP Code:
    package src.Verbs;
    
    import src.Operations;
    
    public class SimplePresent {
    
        public static Boolean Test(String string) {
        	String[] verbs = string.split(" ");
        	for ( int x = 0;x<verbs.length;x++){
        		String word = verbs[x];
        		if (word.substring(word.length()-3,word.length()).equals("ies")){
        			word = word.substring(1,word.length()-3);
        			if (Operations.Find("Verbs.txt",word) != false){
        				return true;
        			}
        		} else {
        			if (word.substring(word.length()-2,word.length()).equals("es")){
        				word = word.substring(1,word.length()-2);
        				if (Operations.Find("Verbs.txt",word) != false){
        				return true;
        				}
        			} else {
        				if (word.substring(word.length()-2,word.length()).equals("es")){
        					word = word.substring(1,word.length()-2);
        					if (Operations.Find("Verbs.txt",word) != false){
        						return true;
        					}
        				}
        			}
        		}
        	}
        	return false;
        }
        
        
    }

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    Each package has to be in it's own folder, i believe. Is that the issue?

    /src/Verbs/SimplePresent.java
    My Hobby Project: LegacyClone

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mrmatt1111 View Post
    Is that the issue?
    Quite hard to tell as the original poster has kept a lot of the details to himself.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    So you have a class called src.Verbs and a package called src.Verbs as well?
    The compiler will give you a warning for that.
    If that is not the case then post the exact error message you are getting.

  5. #5
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    I tought when wrighting a package i should wright;
    package pathFromClassPathToScript;

    so the script is inside the Verbs forder.
    the Verbs fordel inside the src folder, and the src folder inside the classpath folder.

    So shouldnt it be src.Verbs; for all packages inside the verb folder?

  6. #6
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    "for all packages inside the verb folder"

    This statement doesn't make sense.

    A package is a collection of classes (NOT SCRIPTS! :P) contained in a folder.

    A class belongs to a package but is not a package.

    To say:

    Java Code:
    package pathFromClassPathToScript;
    is to say that this class belongs to this package which happens to also give it's location in the folder structure.

    Example:

    %ClassPath%/project
    package project;

    %ClassPath%/project/verbs
    package project.verbs;

    Also:

    import project.verbs.*; //to access the classes in this package from outside the package
    Last edited by mrmatt1111; 09-01-2009 at 08:56 PM.
    My Hobby Project: LegacyClone

  7. #7
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Ok so how do I make it a package?
    package src.Verbs SimplePresentForFutureEvents;
    Will only cause the error "; expected"

    and
    package src.Verbs.SimplePresentForFutureEvents;

    doesnt help..
    NOTHING works!
    What am I suppose to do!

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by Addez View Post
    ...
    What am I suppose to do!
    Read the tutorials. Don't bother trying to write a single line of code before reading the relevant tutorial.

    Start here.

  9. #9
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    Java Code:
    package src.Verbs;
    
    public class SimplePresentForFutureEvents
    {
       ...
    }
    it assumes this path:

    %ClassPath%/src/Verbs/SimplePresentForFutureEvents.java
    My Hobby Project: LegacyClone

  10. #10
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Yes, that is what I already have, still I get the error...

  11. #11
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    nvm, it was jcreator that had not erased the class file when i deleted the java file..
    So it got meesed up, but now its working!

Similar Threads

  1. Replies: 4
    Last Post: 02-16-2009, 04:20 PM
  2. [SOLVED] Compiling Package Class
    By nwboy74 in forum New To Java
    Replies: 3
    Last Post: 11-15-2008, 12:19 AM
  3. How to use Stack class in java.util package
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:32 PM
  4. Compiling a class in a package from cmd
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 11:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •