Error at execution: java.lang.NoClassDefFoundError [message #948800] |
Thu, 18 October 2012 11:42 |
|
Hello,
I am writing a simple program in Java using the ATL API.
I want to use this API to compile my .atl file to a .asm file.
This is the code:
import org.eclipse.m2m.atl.engine.compiler.AtlCompiler;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.File;
import java.io.IOException;
public class MyClass
{
public static void main(String[] args)
{
File inputFile = new File("myfile.atl");
File outputFile = new File("myfile.asm");
FileInputStream fileInputStream = null;
try
{
fileInputStream = new FileInputStream(inputFile);
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
FileOutputStream fileOutputStream = null;
try
{
fileOutputStream = new FileOutputStream(outputFile);
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
try
{
AtlCompiler.compile(fileInputStream, fileOutputStream);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
In command line:
In order to compile it, I need these JAR files in the classpath:
org.eclipse.m2m.atl.engine_3.3.0.v201205241358.jar
org.eclipse.core.resources_3.8.0.v20120522-2034.jar
org.eclipse.emf.ecore_2.8.0.v20120606-0717.jar
In order to execute, I need these JAR files in the classpath:
org.eclipse.emf.ecore_2.8.0.v20120606-0717.jar
org.eclipse.emf.common_2.8.0.v20120606-0717.jar
org.eclipse.emf.ecore.xmi_2.8.0.v20120606-0717.jar
org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
org.eclipse.m2m.atl.common_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.core_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.core.emf_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.engine_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.engine.emfvm_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.dsls_3.3.0.v201205241358.jar
But I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/m2m/atl/engine/compiler/AtlCompiler
at main.Main.main(Main.java:35)
Caused by: java.lang.ClassNotFoundException: org.eclipse.m2m.atl.engine.compiler.AtlCompiler
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
make: *** [run] Error 1
On Eclipse:
In order to compile/execute, I need to add these JAR files in Java Build Path > Libraries:
org.eclipse.core.resources_3.8.0.v20120522-2034.jar
org.eclipse.emf.ecore_2.8.0.v20120606-0717.jar
org.eclipse.emf.common_2.8.0.v20120606-0717.jar
org.eclipse.emf.ecore.xmi_2.8.0.v20120606-0717.jar
org.eclipse.equinox.common_3.6.100.v20120522-1841.jar
org.eclipse.m2m.atl.common_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.core_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.core.emf_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.engine_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.engine.emfvm_3.3.0.v201205241358.jar
org.eclipse.m2m.atl.dsls_3.3.0.v201205241358.jar
org.antlr.runtime_3.0.0.v200803061811.jar
org.eclipse.core.runtime_3.8.0.v20120521-2346.jar
But I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.core.runtime.Platform
at org.eclipse.m2m.atl.engine.compiler.AtlDefaultCompiler.internalCompile(AtlDefaultCompiler.java:204)
at org.eclipse.m2m.atl.engine.compiler.AtlDefaultCompiler.compileWithProblemModel(AtlDefaultCompiler.java:94)
at org.eclipse.m2m.atl.engine.compiler.AtlCompiler.compile(AtlCompiler.java:182)
at MyClass.main(MyClass.java:35)
So, in both cases (command line and Eclipse), I can't run my program.
I am using Eclipse 4.2.0, ATL 3.3.0 and Java 1.6.0_25.
Do you see where is the problem?
Thank you.
Regards.
|
|
|
Re: Error at execution: java.lang.NoClassDefFoundError [message #958976 is a reply to message #948800] |
Fri, 26 October 2012 11:02 |
|
I found a way to make it work :)
The code is good, there is nothing to change.
But in Eclipse, instead of create a Java project, create a Plug-in project.
Then add the following dependencies:
Require-Bundle: org.eclipse.m2m.atl.engine;bundle-version="3.3.0",
org.eclipse.core.resources;bundle-version="3.8.0",
org.eclipse.m2m.atl.common;bundle-version="3.3.0",
org.eclipse.m2m.atl.engine.emfvm;bundle-version="3.3.0",
org.eclipse.m2m.atl.dsls;bundle-version="3.3.0"
And it just works :)
I don't know why I need to create a Plug-in project instead of a Java project...
Do you know why?
Thank you.
Regards.
[Updated on: Fri, 26 October 2012 20:11] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04117 seconds