Apache Ant: Could not find the main class. Program will exit - java

I am trying to build a project using ANT using JDK 1.3 as a JRE (this version is required for this specific build). Also, I am using the following:
Eclipse Version: Luna Service Release 1 (4.4.1).
Ant version 1.7.1
When I try to build the project I get an error message saying: "Could not find the main class. Program will exit!". The JVM can't find the main class.
But when building using JDK 1.6.0 it works fine. What could be the cause of this error?
Why is it not possible to build with JDK 1.3?
I would really appreciate your input!
Best regards

Thank you for your input guys. I have a workaround to this problem. I ran ANT through the command line. Then it everything works as intended. Thus, it seems that the eclipse version that i am using does not support the use of JDK1.3.

Related

ERROR: Could not determine java version from '15.0.2'

Hey so I was trying to run the command ./gradlew setupDecompWorkspace on the windows powershell and it gave me an error as shown in the image. I also checked to see what version of gradle I was using and it said gradle-2.7-bin.zip inside the gradle-wrapper.properties and I tried upgrading the version via powershell using a command but the term gradle is not recognized. Please help me solve this issue since i need to do this for forge api.
Gradle 2.7 is an ancient version of Gradle from 2015. Java 15.x did not exist at that time. This version of Gradle does not know about it.
I think you might have more success when you try to run this build with Java 8.

Why is IntelliJ IDEA unable to determine java version?

I'm rather new to IntelliJ IDEA and Grails in general. I just started a new Project, selected my project JDK (11.0.1) and Gradle distribution (4.10.2). Whenever I try to run the project, I get this error:
Error initializing classpath: Could not determine java version from
'11.0.1'. java.lang.IllegalArgumentException: Could not determine java
version from '11.0.1'. at
org.gradle.api.JavaVersion.toVersion(JavaVersion.java:68) at
org.gradle.api.JavaVersion.current(JavaVersion.java:78) at
org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeException.java:29)
at
org.gradle.tooling.internal.consumer.ConnectorServices.checkJavaVersion(ConnectorServices.java:66)
at
org.gradle.tooling.internal.consumer.ConnectorServices.close(ConnectorServices.java:53)
at
org.gradle.tooling.internal.consumer.DefaultGradleConnector.close(DefaultGradleConnector.java:57)
at
org.grails.cli.gradle.cache.CachedGradleOperation.call(CachedGradleOperation.groovy:78)
at
org.grails.cli.GrailsCli.populateContextLoader(GrailsCli.groovy:525)
at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:508)
at
org.grails.cli.GrailsCli.initializeApplication(GrailsCli.groovy:306)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:269) at
org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
All other discussions of the problem I found suggested changing the Gradle distribution, which I already did. I would be so happy if anybody could help me out here.
Cheers!
May be your java configuration is not correct. If not correct follow this steps.
Goto File-> Project Structure.
Change SDK
Or gradle version is not matching jdk 11 then skip this answer.
Besides the issue with Gradle above, if you're trying to run a Grails project I don't think you can do that with JDK higher than version 8.
Even the latest Grails (3.3.8 as of this writing) is still based on SpringBoot 1.5 which does not support newer JDK, I don't know if there's a special trick to make it work.
I had to delete the .gradle directory and restart Intellij.

Need help on NoClassDefFound error

I'm working on a service to prepare spreadsheet for a report. I'm using jxl-2.4.2.jar to achieve this ( please note that I can't use the latest version due to compatibility constraints). When I execute the code locally on my eclipse it works fine. My eclipse has java 1.5.
When I deploy my code in my test environment, its giving NoClassdefFound error for jxl.* ( any classes in jxl ). My test environment has IBM's java 1.5. I believe it doesn't make any difference if I use IBM's version or Sun's version of java in this context.
I believe this error could happen when JVM fails to load the class at runtime or if the class has any static methods/properties. I checked the classes and none of them have static contents. So, this could be something else.
FYI.. I'm using ant to build the project & I check the build.xml. It is showing the correct version of java 1.5. Could someone please help to fix this error? Also Just FYI.. my project resides on AIX 5.0 server.
Any help in this regard much appreciated. Thanks in advance.
This error implies that your dependency is missing at runtime i.e. the set of dependent jars is not not correct.
jxl-2.4.2.jar is not getting shipped along with deployment, so just to resolve the issue , you can manually copy this jar in dependent lib folder of deployment.
But proper fix will be to get your ANT build checked.

Unable to run Java Applications in Eclipse [duplicate]

I'm trying to get started with Eclipse/Java/Scala on a MacBook. The installed JDK was 1.5. The SDT plugin for Scala requires 1.6 which was included in an OS update, but I also manually installed a package from Apple to update 1.6.
The problem is that I cannot run anything from Eclipse. I always get the following error:
An internal error occurred during: "Launching TestFooBasicTest".
Could not initialize class com.ibm.icu.impl.JavaTimeZone
I also tried to use the old 1.5 version, but to no avail.
What is going wrong here?
I had the same problem trying to run a scala program with Ubuntu 10.4 and stock eclipse (Galileo 3.5.2) and java (java-6-openJdk ) - and the scala pluging downloaded from scala site, of course. I fixed it by manually changing /usr/lib/eclipse/plugins/com.ibm.icu_4.0.1.v20100125.jar as suggested in this thread (btw I discovered that Emacs can change a jar file in place: nice):
http://www.eclipse.org/forums/index.php?t=msg&goto=488654
It's caused by ubuntu openjdk package with broken symbol links for TimeZone configuration. The best solution from forum thread is,
Reinstalling tzdata-java was the fix for me:
sudo apt-get --reinstall install tzdata-java
The problem is:
An internal error occurred during: "Launching TestFooBasicTest". Could not initialize class com.ibm.icu.impl.JavaTimeZone
A quick google search reveals that this class belongs to the IBM Globalization package ICU. http://www-01.ibm.com/software/globalization/icu/index.jsp
A guess would be that this is a package used internally by Scala that you have not installed properly, causing Scala startup to fail.
Make sure that you set java 1.6 in the run configuration (Run/Run configurations).
Did you upgrade to Snow Leopard? Are you using the Eclipse SWT/Carbon or the Eclipse SWT/Cocoa? I was seeing some strangeness with Eclipse after I upgraded to SL. Switching to the Eclipse SWT/Cocoa from Eclipse SWT/Carbon helped. Also restoring my 1.5 VM, which the SL install removes in a sneaky way(by deleting and leaving the symbolic link pointing to 1.6), helped me fix several issues with Java code that had natives(i.e. usb-serial port code).
Check what are the JVMs that Eclipse is aware of and where they are located (Preferences -> Java -> Installed JRE), and also check the run/debug configuration of your programs. By default, Eclipse knows about the JRE that was used to launch itself, and other JREs that you add manually. However, if you upgrade some components and the JREs changed, Eclipse can get "confused" about them.
I had this same issue with Eclipse on Windows. I tried a number of different things including a new hello world program in a new workspace. I finally got this to work by pointing Eclipse to a different JRE to execute with. I know that Apple provides the JRE for Mac, but it does seem like this issue is related to Eclipse having trouble with the JRE used to run Eclipse itself. See here for configuring which VM Eclipse executes with.

bad version in class file

When I use certain jars in one of the connector projects i write for lombardi in TeamWorks eclipse i get a bad class version exception...
any ideas how this might be resolved..
Regards,
Adhir
You will get this error if you are using (say) Java 1.5 and you are using a JAR compiled with Java 1.6.
The easiest way to resolve is to upgrade your version of Java to the one used by the JAR.
Try to compile/recompile all your stuff with the same compiler.
Typically this happens when you have something compiled with a higher version and
you try to run it with an older one.
This problem can also be caused by an expired (365-day) Android certificate referenced by Eclipse.
See "Debug certificate expired" error in Eclipse Android plugins for details.
This is a result of running code compiled with a compiler version that is greater than the version of java you are using to run it. IE Code compiled with 1.6 and you are running it with 1.5. See this post to determine what version it was compiled with.
how-can-i-find-the-target-java-version-for-a-compiled-class
the easiest fix is to run it with the most recent JVM.
Root Cause for this error is that: jars including in your project is complied from other version of java and you are compiling your project from other version of java simply upgrading version of java will resolve this problem.
I also faced the same problem.

Categories