Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting up packages (very confused)

 
John Jaspers
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realize this is kind of a silly question, but what they heck: If I have a package whos directory structure is say C:\packages\com\whatever and I want to add to the whatever package, how would I do this and have the program find the package? Do I have to add this directory structure to my classpath, because using import statements doesn't seem to do it in JBuilder 8, and I can't figure out what I'm doing wrong.
And after getting it set up correctly, what do I use as the import line? import packages.com.whatever.*, or just com.whatever.*? How would I set it up so that it were only com.whatever.*?
Thanks in advance.
 
Susilo Saja
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Let's say you have a java file C:\package\com\whatever\Test.java, if you put C:\package in your classpath, then the package for Test.java is package com.whatever; And if you want to import Test.java, it will be import com.whatever.Test;
If you already define a package for a class, yes you have to put it in the classpath so that javac and java can find it. But it could be different for IDE. It may look for the CLASSPATH environment variable, or you might have to set the library by your own in that IDE. I don't know about JBuilder. Hope this help.
Susilo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic