Launching single file source code program - "error: class found on application class path"

Jaikiran Pai jai.forums2013 at
Sun Jun 17 10:56:34 UTC 2018

Consider this very simple class:

public class A {
     public static void main(final String[] args) throws Exception {

I built the latest JDK from source and used the "launch single file 
source program" feature as follows:

 > cd /tmp/foo-bar

(this dir contains just file)

 > java

The output is as follows (as expected):


Then I went ahead and did an explicit compilation of this Java file:

 > javac

The /tmp/foo-bar directory now consists of A.class and I then 
went ahead and (tried) to launch the using the new feature as 

 > java

I now get this error message:

error: class found on application class path: A

1. That error message isn't clear about what the problem is. I guess 
it's trying to convey that there's already a compiled class for the same 
source class, in the application classpath?

2. Why is this an error? Is it intentional?


More information about the jdk-dev mailing list