Computer Science Canada importing files |
Author: | Homer_simpson [ Fri Mar 05, 2004 6:38 pm ] |
Post subject: | importing files |
say i got this file i've made so i can import it later where do i gotto save it? and how do i import it? |
Author: | rizzix [ Fri Mar 05, 2004 6:52 pm ] | ||
Post subject: | |||
k u don't need to use the import keyword unless ur code is in a package. now after u compile all ur code. u'll get the respective classes. so if these classes compose ur library. and u wish to use them in code els where. all u need to do is copy those .class files into the same directory of ur current project. then simply compile ur code like this:
note, u don't really need add any extra lines into ur code to use those classes. its all automaticly taken care of. |
Author: | Homer_simpson [ Fri Mar 05, 2004 6:55 pm ] |
Post subject: | |
yup! thx alot man! |
Author: | rizzix [ Fri Mar 05, 2004 6:56 pm ] |
Post subject: | |
also it might sometimes make it easier to package a library of classes into a .jar archive. and at times if it is soo frequently used u can also drop that .jar (or .class files) into the ext dir in ur java root directory. |
Author: | Homer_simpson [ Fri Mar 05, 2004 8:15 pm ] |
Post subject: | |
not a bad idea... only if i knew how to turn my files into a package :S |
Author: | rizzix [ Sat Mar 06, 2004 1:58 pm ] |
Post subject: | |
it is really easy. all u need to do is add the line package name_of_package; at the top of each file to denote that those classes defined in those .java files to be in that perticular package. next u compile these files then u move the respective .class files into a new directory that has the same name as that of the package. now go and download the jarmaker utility i created (somewhere in the java submissions). now create a blank file with the word "manifest" in it's name. drag both the directory and that file onto the jarmaker, it should generate a .jar file. ur done. ![]() |
Author: | rizzix [ Sat Mar 06, 2004 2:19 pm ] | ||
Post subject: | |||
also note: compiling against a jar archive has a slightly different syntax:
|