ResourceSet rs = new ResourceSetImpl();
Resource r = new ResourceImpl();
rs.getResources().add(r);

Model m = JavaFactory.eINSTANCE.createModel();
m.setName("modelFromScratch");

CompilationUnit cu = JavaFactory.eINSTANCE.createCompilationUnit();
cu.setName("MyNewClass.java");
m.getCompilationUnits().add(cu);

org.eclipse.gmt.modisco.java.Package pkg = JavaFactory.eINSTANCE.createPackage();
pkg.setName("newPkg");
m.getOwnedElements().add(pkg);

ClassDeclaration c = JavaFactory.eINSTANCE.createClassDeclaration();
c.setName("MyNewClass");
cu.getTypes().add(c);
pkg.getOwnedElements().add(c);

r.getContents().add(m);
javaGenerator = new Generate_JavaStructures(m,
new File("C:/.../myOutputFolder"),
new ArrayList<Object>());

r.setURI(URI.createFileURI("x.javaxmi"));

javaGenerator.doGenerate(null);