Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package Name

 
Mayowa Bakare
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I create a classpath for Package name? e.g .;C: \mypackage in Environment Variables on Windows
 
Stephan van Hulst
Bartender
Pie
Posts: 5567
53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Packages are located at class paths. No part of the package file hierarchy should appear in the class path.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
John Webb
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch John Webb
 
Mayowa Bakare
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your classpath to:

.;C:\

then you should be able to use javac as such:

javac world/HelloWorld.java
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic