File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Package Name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package Name" Watch "Package Name" New topic
Author

Package Name

Mayowa Bakare
Greenhorn

Joined: Jun 03, 2012
Posts: 3
How can I create a classpath for Package name? e.g .;C: \mypackage in Environment Variables on Windows
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3900
    
  18

Packages are located at class paths. No part of the package file hierarchy should appear in the class path.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43381
    
  32
And welcome to the Ranch
John Webb
Greenhorn

Joined: Jun 05, 2012
Posts: 2
Use the IDE to and supply the current class a package name using for example:
package coderanch.ex1

and the folders will be created for you.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43381
    
  32
Welcome to the Ranch John Webb
Mayowa Bakare
Greenhorn

Joined: Jun 03, 2012
Posts: 3
Thank you all, for your contribution . But I cannot compile package name . E.g package world; public class HelloWorld{ public static void main(String args ){ System.out.println("HelloWorld"); } } each time I compile package name like this it gives error:NoClassDefError wrong world/HelloWorld. But I created a folder on world in C: \ directory of my harddisk and configure the classpath like .;C: \ world in the environmental variable in Windows XP, and enter javac to compile it, it compile and enter java to run it it gives error:NoClassDefFoundError wrong World. This is the problem I am facing right now, please help!
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1051
    
    5

Change your classpath to:

.;C:\

then you should be able to use javac as such:

javac world/HelloWorld.java
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43381
    
  32
You are usually better off using the -cp option for classpaths; if you change a system classpath it can do more harm than good.
Mayowa Bakare
Greenhorn

Joined: Jun 03, 2012
Posts: 3
Hi, James Boswell thank you very much I can now run a complete application with package name. I also thanks others contributions that help to solve this problem.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Package Name
 
It's not a secret anymore!