[Bug 522333] "Error: Could not find or load main class
o.c.p.c.l.Launcher" when running Eclipse Java 9 Beta

Change-Id: I525763582d4eaa81cbde0294e8e54baa0ab3c41e
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java
index 51e5299..1d20f4e 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaLaunchDelegate.java
@@ -84,10 +84,12 @@
 			runConfig.setVMSpecificAttributesMap(vmAttributesMap);
 			// current module name, if so
 			IJavaProject proj = JavaRuntime.getJavaProject(configuration);
-			IModuleDescription module = proj == null ? null : proj.getModuleDescription();
-			String modName = module == null ? null : module.getElementName();
-			if (modName != null) {
-				runConfig.setModuleDescription(modName);
+			if (proj != null) {
+				IModuleDescription module = proj == null ? null : proj.getModuleDescription();
+				String modName = module == null ? null : module.getElementName();
+				if (modName != null) {
+					runConfig.setModuleDescription(modName);
+				}
 			}
 
 			// Bootpath
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
index 4d9d3da..f11f2d7 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
@@ -1530,10 +1530,15 @@
 				switch (entry.getClasspathEntry().getEntryKind()) {
 					case IClasspathEntry.CPE_LIBRARY:
 						IJavaProject project = JavaRuntime.getJavaProject(configuration);
-						IPackageFragmentRoot root = project.findPackageFragmentRoot(entry.getPath());
-						if (root != null && !root.getRawClasspathEntry().getPath().segment(0).contains("JRE_CONTAINER")) { //$NON-NLS-1$
+						if (project == null) {
 							entries2.add(entry);
 						}
+						else {
+							IPackageFragmentRoot root = project.findPackageFragmentRoot(entry.getPath());
+							if (root != null && !root.getRawClasspathEntry().getPath().segment(0).contains("JRE_CONTAINER")) { //$NON-NLS-1$
+								entries2.add(entry);
+							}
+						}
 						break;
 					default:
 						entries2.add(entry);