aspose 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
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: 3647
    
  16

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

Joined: Oct 13, 2005
Posts: 38881
    
  23
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: 38881
    
  23
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: 1021
    
    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: 38881
    
  23
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.
 
Consider Paul's rocket mass heater.
 
subject: Package Name