Android Question "Could not find or load main class com.sun.tools.javac.Main"

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
My anti-virus program said I needed to install Java 7 but before doing so, I should uninstall Java 6. After doing both steps, when I try to compile in B4A, I get the message: "Could not find or load main class com.sun.tools.javac.Main".

I broke out the Beginners Guide and didn't see this mentioned and also searched the threads here, but don't see any help on this.
 

warwound

Expert
Licensed User
Longtime User
Just an idea...

Has the old version of java had it's path added to the System PATH variable, then you uninstalled it and the path is still set - to a non-existent location?
So any program looking for the installed java is looking in the wrong place?

Open a command prompt and enter:

B4X:
java -version

Is 'java' found and if so does it say version 1.7.?

You can find info on editing your System PATH variable: https://www.google.co.uk/search?q=windows+edit+system+path+variable&ie=UTF-8&oe=UTF-8.

Martin.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Are you sure that you installed Java JDK and not JRE? The link to the correct package is available here: www.b4x.com/android/downloads.html

The first time I uninstalled Java 6 and installed jdk-7u25-windows-x64.exe from the Oracle.com download page.
I changed the Paths in B4A's IDE Tools and got the error.

Note that if the Path is not correct, I get a different error: JAVAC.exe not found.
The error I'm getting is: "Could not find or load main class com.sun.tools.javac.Main".

I did a Win7 recovery to a point prior to installing jdk7 and got back to my original jdk6, same ("javac.Main") error, which is strange because I never got that error before with jdk6.
I looked for the B4A installation instructions on here (same link you gave me above), installed jdk7 from that page, same error.
I Googled the error message. Turns out that this is not an unusual problem, but there were all kinds of suggested fixes.
I tried some of them but always got the same error.

Uninstalled Java, redownloaded and reinstalled B4A, reinstalled jdk7 from the B4A page link, same error.

After getting your post I uninstalled Java, downloaded jdk7 from the B4A page link (again). When I started B4A by clicking on my app's name and got a new B4A loading error: "The system cannot find the file specified." -- Doesn't say what file. But when I compiled, it worked, except that it said "Optimized dexer failed. Using standard dexer." I closed B4A and restarted it as before and didn't get the error about "cannot find the file specified." I compiled and didn't get the dexer message or any other errors.

So everything seems to be working right again, but I have no clue why the jdk7 from the B4A link worked this time and not other times nor why the jdk from the Oracle page didn't work nor why anything else I tried over the last 2 days didn't work and suddenly does. Oh, well...
 
Last edited:
Upvote 0
Top