source file name: rangeprimenocmd.java
class rangeprimenocmd
{
void prime(int n)
{
int d=2;
while(d<n)
{
if(n%d==0)
break;
else
d++;
}
if(d==n)
System.out.print(n+" ");
}
public static void main(String args[])
{
rangeprimenocmd p=new rangeprimenocmd();
int n1=Integer.parseInt(args[0]);
int n2=Integer.parseInt(args[1]);
if(n1<n2)
{
int n;
System.out.println("prime numbers between "+n1+" and "+n2+" are follows:");
for(n=n1;n<=n2;n++)
{
p.prime(n);
}
}
else
System.out.println("sorry please enter first less than second no ");
}
}

output:
D:\JavaPrograms\CmdPrograms>javac rangeprimenocmd.java

D:\JavaPrograms\CmdPrograms>java rangeprimenocmd 1 300
prime numbers between 1 and 300 are follows:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 1
07 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 2
23 227 229 233 239 241 251 257 263 269 271 277 281 283 293

D:\JavaPrograms\CmdPrograms>java rangeprimenocmd 20 10
sorry please enter first less than second no