It's OK if this is homework; just don't expect anyone to do it for you. If you're interested in help, then that's cool.
I added our UBB "CODE" tags to your post and fixed up the formatting to make your code a bit easier to follow.
The truth is you have a pretty good start here, and the major problem to be dealt with is that the printing and testing in the innermost nested loop shouldn't be where it is. Look at the code and think hard about when you want to do what -- in other words, after I've done all of X, then I should do Y. To make something happen after a loop runs all the way through, you'd need to put the code for that something outside the closing bracket at the end of the loop. Some things can happen outside of one loop, but inside of another, if you get my meaning.
Hi I wrote this program a while ago, but I'm not going to give you the solution since I will be banned from the site. Anyway, this is a tad complex and requires a little thought.
One improvement you should make, you only need to test for divisor upto the square root of the number you're testing. so if X is the number to test, the biggest number to check for division will be (int)Math.sqrt(X)
That will make a huge difference to efficiency if you're testing for primes of size 1,000,000 or more.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com