Results 1 to 5 of 5
Thread: How to use my own packages?
- 04-21-2011, 11:19 PM #1
Member
- Join Date
- Apr 2011
- Location
- Krakow, Poland
- Posts
- 2
- Rep Power
- 0
How to use my own packages?
How can I import my own packages into .java files from different packages without setting the CLASSPATH variable and only specifying javac -claspath <path>?
i.e. I have a folder Program and in this folder I have bin and src folders. Where should I put my package files? I tried and put them into src/com/mydomainname/mypackage and then I created another file, in the /src directory, Main.java in which I added statement "import com.mydomainname.mypackage.*;"
Then, when compiling from my Program directory, I used "javac Main.java -classpath /src" and it didn't work.
How can I make this work? What's the usual place to put your own packages in?
- 04-21-2011, 11:33 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
What do you mean "it didn't work" ? Did you get any errors? If so what were they? Make sure the folders and package and import match the case of the folder names.
You may have to expand the -cp with something like
Java Code:javac -cp .;source folder file.java
- 04-21-2011, 11:40 PM #3
Member
- Join Date
- Apr 2011
- Location
- Krakow, Poland
- Posts
- 2
- Rep Power
- 0
The error I get is "package com.mydomainname does not exist".
It still doesn't work when I use "javac -cp ./src Main.java" .
- 04-21-2011, 11:43 PM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Did you separate the two with a semi colon? What is the package statement in the packaged code? Did you compile the package code? I am not great with packaes either but I am giving you some ideas to try until someone with more experience comes along.
- 04-22-2011, 04:53 AM #5
Similar Threads
-
Packages
By urbim in forum EclipseReplies: 2Last Post: 07-02-2009, 02:01 PM -
packages
By fogus in forum New To JavaReplies: 1Last Post: 03-24-2009, 06:14 AM -
Importing packages from the packages within same application.
By sta2003 in forum New To JavaReplies: 3Last Post: 02-12-2008, 11:03 AM -
packages
By ai_2007 in forum Advanced JavaReplies: 1Last Post: 07-31-2007, 12:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks