Your problem is that you are looping only once.
For example when j = 2
you only check if 1475 is divisible by b[2]
which happens to be 4 and 1475 is not divisible by 4 thus printing your value.
You'll need to use a nested loop to achieve what you are trying to do.
Here is a bit of code to help out:
private static void smallestPrime() {
long m = 0;
int[] b = { 2, 3, 4, 5, 6, 7, 8 };
for (int j = 0; j <= 6; j++) {
m = (long) Math.pow(38, j) + 31;
boolean prime = true;
for (int i = 0; i <= 6; i++) {
if (m % b[i] == 0) {
prime = false;
break;
}
}
System.out.println(m + " : " + prime);
}
}