java - Create source folder and project programmatically -


i trying create 1 java project source folder programmatically.i able create java project inside not able create source folder getting error below.

java.lang.arraystoreexception     @ java.util.abstractcollection.toarray(abstractcollection.java:171)     @ org.eclipse.jdt.launching.javaruntime.getvminstalltypes(javaruntime.java:533)     @ org.eclipse.jdt.launching.javaruntime.getvminstalltype(javaruntime.java:414)     @ org.eclipse.jdt.internal.launching.vmdefinitionscontainer.populatevmtypes(vmdefinitionscontainer.java:483)     @ org.eclipse.jdt.internal.launching.vmdefinitionscontainer.parsexmlintocontainer(vmdefinitionscontainer.java:467)     @ org.eclipse.jdt.launching.javaruntime.addpersistedvms(javaruntime.java:1488)     @ org.eclipse.jdt.launching.javaruntime.initializevms(javaruntime.java:2654)     @ org.eclipse.jdt.launching.javaruntime.getdefaultvmid(javaruntime.java:541)     @ org.eclipse.jdt.launching.javaruntime.getdefaultvminstall(javaruntime.java:486) 

i have tried below code creating java project , source folder programmatically.

iworkspaceroot root = resourcesplugin.getworkspace().getroot(); iproject project = root.getproject(projectname); project.create(null); project.open(null); iprojectdescription description = project.getdescription(); description.setnatureids(new string[] { javacore.nature_id }); project.setdescription(description, null); ijavaproject javaproject = javacore.create(project);  ifolder binfolder = project.getfolder("bin"); binfolder.create(false, true, null); javaproject.setoutputlocation(binfolder.getfullpath(), null); list<iclasspathentry> entries = new arraylist<iclasspathentry>(); ivminstall vminstall = javaruntime.getdefaultvminstall(); librarylocation[] locations = javaruntime.getlibrarylocations(vminstall); (librarylocation element : locations) {  entries.add(javacore.newlibraryentry(element.getsystemlibrarypath(), null, null)); } //add libs project class path javaproject.setrawclasspath(entries.toarray(new iclasspathentry[entries.size()]), null); ifolder sourcefolder = project.getfolder("src"); sourcefolder.create(false, true, null); packagefragmentroot root = javaproject.getpackagefragmentroot(sourcefolder); iclasspathentry[] oldentries = javaproject.getrawclasspath(); iclasspathentry[] newentries = new iclasspathentry[oldentries.length + 1]; system.arraycopy(oldentries, 0, newentries, 0, oldentries.length); newentries[oldentries.length] = javacore.newsourceentry(root.getpath()); javaproject.setrawclasspath(newentries, null); 

is there wrong? how can create source folder programmatically ?


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -