This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package name

 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i'm compiling this following code, i can't get the package name. I doesn't create a package name 'engin' :
package engin;
public class exemple {
public static void main (String args[]){

System.out.println("Hello");
}
}
It works but I should have the exemple.class in the pachage engin but where is this package. Normally when we are compiling it must create a the package name by itself, isn't it?
Thank you.
 
friso jonge
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
first of all, i think you placed this in the wrong discussion. But since it is close to christmas, we all loosen up a bit and try to give a answer.
I am assuming you use an IDE. In the same place where you created this exemple class, create another class, not adding any package information, and not importing any package. Then try to create the object exemple without using the engin word. If this works, then indeed you did not create a package.
If it does not work, import package engine with : import engine.exemple;
That should work.
So where is this package. Well, i dont know, this depends on the settings of your IDE. What you could do is try to do a find/grep on your filesystem on exemple.class. This should be in a directory called..... engine.
That is your package.
cheers,
friso
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry but i'm not using an IDE.I don't what can be my problem ???Anybody has idea ?thank you
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now it's OK.
When i write : javac -d ../ exemple.java ,
i can get my folder engin in wich is my file exemple.class, i want to understand why when i write : javac exemple.java ,i can't get this folder ?
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this question does not belong to SCWCD forum.
Oh well. Let's complete the thread.
The -d option will create the necessary dirs needed by the class in a package.Here is a good link.
http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javac.html#options

-d directory
Set the destination directory for class files. The destination directory must already exist; javac will not create the destination directory. If a class is part of a package, javac puts the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify -d c:\myclasses and the class is called com.mypackage.MyClass, then the class file is called c:\myclasses\com\mypackage\MyClass.class.
If -d is not specified, javac puts the class file in the same directory as the source file.
Note that the directory specified by -d is not automatically added to your user class path.

Regards,
Maha Anna
[ November 26, 2002: Message edited by: Maha Annadurai ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic