Results 1 to 2 of 2
- 10-19-2010, 09:35 PM #1Member
- Join Date
- Oct 2010
- Rep Power
Embarrassingly basic and bad question
I am googled out in trying to figure out something that is going to be quite embarrassing, I am sure.
I write programs for my use only, usually just filtering out large amounts of data from a series of flat files and then spitting out the results. Sometimes I do a lot of analysis, number crunching, etc.
I am not a real programmer and I have only used the standard java library. I decided for some of my pattern recognition to download some prebuilt stuff from apache commons (specifically apache commons math).
Let's say I have a huge depository of files, say c:\java\patternanalysis\
(I am in windows and no, I didn't create a project, separate source/class directories, etc and I know that is poor programming). I extracted the jar that I wanted and now I have c:\java\patternanalysis\org\apache\commons\math... (once in math there are lots of classes and directories)...
Here is the pathetic part, how do I use an import statement to use this?
Oh I don't and can't see myself ever using an IDE, I use notepad++ just for some color coding. Don't know if that is important.
Thank you in advance,
- 10-20-2010, 12:36 AM #2Moderator
- Join Date
- Feb 2009
- New Zealand
- Rep Power
You import as yu would anything from the standard libraries:
It is when you compile or run your program that the fun starts.
I don't know exactly what you meant by saying you extracted the jar. Take the zip download file (like commons-math-2.1.zip) and put the jar file (commons.math-2.1.jar) somewhere you can find it later. But don't extract the contents of this jar file.
When you compile or run a Java program you will need to specify the locations of classes so that the import statement will work at comple time and so that the actual classes will be located at runtime. Typical compile and run commands to be executed in the directory that contains the packages *you* have written might look like:
javac -cp .;\jars\commons-math-2.1.jar main\MyApp.java java -cp .;\jars\commons-math-2.1.jar main.MyApp
The -cp switch expects a ; separated list of all the class locations (either directories or jar files: \jars is just somewhere I am supposing you put your jar files.)
- By wulfgarpro in forum New To JavaReplies: 4Last Post: 09-15-2010, 09:49 AM
- By casid in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 12-28-2009, 06:51 PM
- By madthinker in forum New To JavaReplies: 7Last Post: 01-26-2009, 07:09 PM
- By javaplus in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 07-15-2008, 05:44 PM
- By gvi in forum New To JavaReplies: 2Last Post: 10-30-2007, 06:30 PM