This is only tested with UnrealIRCd 3.2
Code:
 on *:snotice:*client connecting:*:{
  if java !isin $10 {
    .enable #no.java.whois
    .whois $9
    kline %kline 
  }
  else {
    invite $9 #teens
  }
}
#no.java.whois off
raw 378:*:{
  set %kline $gettok($iif(!$7,$6,$7),1--1,46) $+ .*
  haltdef
}
raw 318:*:{
  .disable #no.java.whois
  haltdef
}
#no.java.whois end
 


As to the CTCP version request, that isn't really feasible, due to the fact that someone could script a CTCP version response that says java.

Quite frankly, I find it kind of interesting that you're asking for help on an mIRC forum for a script (which presumably will be used in mIRC) that will disallow people using mIRC from chatting on your network. Heck, never mind interesting, try contradictory.