views:

1256

answers:

3

I can build my application cleanly on windows and Mac OS X but on windows when i try to run the application i get a class not found exception about my main class

main$4 not found.

class is there and it build cleanly. why can't it locate the class file? Jar works in OS X.

Jar is created like the following.

  <target name="jar" depends="">
  <jar destfile="build/application.jar" > 
    <manifest>
      <attribute name="Built-By" value="Hamza"/>
      <attribute name="Main-Class" value="application"/>
    </manifest>
    <fileset dir="build">
      <include name="**/*.class"/>
  <include name="**/*.png"/> 
      <exclude name="**/*.jar"/>
    </fileset>
  </jar>
</target>

i can run it without any errors on OS X but in Windows i get class not found exceptions.

+1  A: 

Is it run with the same JVM ? main$4 seems to indicate it's an anonymous class which is not found. Hard to help you without more information. Maybe provide a piece of code and some stacktrace, and the JRE versions you're using ?

Typo there : cleanly on windows and Mac OS X but on windows

g andrieu
A: 

Not much information, but it looks like an anonymous class in your main class cannot resolve some dependency it has and thus cannot be created.

Also, there is a difference between your build time and runtime class paths. Your actual runtime can potentially require more jars than the build.

For example, a jar containing an interface that you reference in your code would be required for your code to build, but you will require jars with the implementations of that interface for your code to run.

EDIT: Your update shows your build, which you already said works (which OS doesn't matter) as this is Java. Your problem is the classpath at runtime. Do you have a classpath environment variable set in one OS and not the other? We cannot tell from this what your dependencies are. Knowing the contents of the anonymous classes involved would help figure out what dependency is missing.

Robin
+1  A: 

Is the Main-Class attribute really set to "application"?

Main-Class should indicate the relative path to the class you want to run, e.g. "myPackage.Application", or simply "Main".

Manuel