Skip to content

Commit e436a06

Browse files
committed
Added class path arg, not working still
1 parent 50e163d commit e436a06

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drjava/src/edu/rice/cs/drjava/model/repl/newjvm/InterpreterJVM.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@
7474
import java.util.List;
7575
import java.util.Locale;
7676
import java.util.stream.Collectors;
77+
import java.util.stream.StreamSupport;
7778

7879
// For Windows focus fix
7980
import javax.swing.JDialog;
81+
import javax.tools.StandardLocation;
8082

8183
import static edu.rice.cs.plt.debug.DebugUtil.debug;
8284
import static edu.rice.cs.plt.debug.DebugUtil.error;
@@ -160,7 +162,11 @@ public void write(int b) {
160162
});
161163

162164
try {
163-
_js = JShell.builder().out(printStream).err(printStream).build();
165+
_js = JShell.builder()
166+
.out(printStream)
167+
.err(printStream)
168+
.compilerOptions("-classpath", getClassPathString())
169+
.build();
164170
} catch(IllegalStateException e) {
165171
//Potentially exit system or try to create a new JShell instance
166172
System.err.println("JShell is not available in this environment");
@@ -704,9 +710,16 @@ public void junitJVMReady() { }
704710
public void addBuildDirectoryClassPath(File f) { _classPathManager.addBuildDirectoryCP(f); }
705711
public void addProjectFilesClassPath(File f) { _classPathManager.addProjectFilesCP(f); }
706712
public void addExternalFilesClassPath(File f) { _classPathManager.addExternalFilesCP(f); }
713+
707714
public Iterable<File> getClassPath() {
708715
// need to make a serializable snapshot
709716
return IterUtil.snapshot(_classPathManager.getClassPath());
710717
}
711-
718+
719+
private String getClassPathString() {
720+
Iterable<File> classPathFiles = _classPathManager.getClassPath();
721+
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(classPathFiles.iterator(), 0), false) // Convert Iterable<File> to Stream<File>
722+
.map(File::getAbsolutePath)
723+
.collect(Collectors.joining(";"));
724+
}
712725
}

0 commit comments

Comments
 (0)