Java detect