Is there a way to find the number of cores in a multi-core system using a command-line, or library function? I want to do this because I want to re-write my programs to be multithreaded and take advantage of multiple cores. Specifically I'm coding in Java, but anything would help. Thanks.

-da