Running Ant Getting Build.xml: starting the Java virtual machine: could not find the main class. The program will be closed

I write my code in eclipse, the code works fine, but when I try to build it in ant by running build.xml . I get

 Java Virtual Machine Launcher: Could not find the main class. Program will exit. 

Any suggestions?

+4
source share
4 answers

You need to check a few things 1) Is the java bin directory path set correctly? (To verify this, you need to write the javac command on the command line (cmd) and you will get a list of instructions in the cmd console)
2) Open the eclipse and go to Window-> Preferences-> Ant β†’ Runtime
on the Classpath tab, see Ant Home entries pointing to the wrong directory (it still points to the last directory, this directory does not exist), you need to do this change Ant Home pointer to the correct directory to indicate Ant Home button - select Ant Home directory, for example, I use Eclipse 3.3.1, Ant Home is the Eclipse org plugin directory. apache.ant_1. 7.0.v200706080842.

+4
source

if you use java 1.6 and updated eclipse, it is most likely caused by eclipse, the solution is to go to Run as β†’ Configure external tools ... β†’ JRE, where the default value is β€œSplit JDK”: jdk1.6.0_31 and change it so to "work in the same JRE as the workspace" (1.7 / 1.8), and it should work.

Bug fixes will be to provide a working default configuration with customization. The configuration should be such that it does not interrupt if the user adds additional JDKs to the settings.

for more details you can see Error 472599

+7
source

If you use Java 1.5 (that is, it is listed in your workspace, project, or ant configuration as the JVM to use), this is also caused by an error / function in Eclipse: Java 1.5 is no longer supported. You need to upgrade to Java 1.6.

See: Eclipse 421423 Errors

+1
source

The version of ant you are using may not be compatible with the version of java you are using. I have ant 1.9.4 and I tried to run with java 1.4 and got the same error. Running with java 1.7 fixed it for me!

0
source

Source: https://habr.com/ru/post/1489201/


All Articles