package org.perl6.rakudo;

import org.perl6.nqp.tools.EvalServer;

public class RakudoEvalServer extends EvalServer {

    private String appname = null;

    public String run(String code) throws Exception {
        return super.run(appname, code);
    }

    public String run(String[] argv) throws Exception {
        return super.run(appname, argv);
    }

    /*
        Neccessary elements in the CLASSPATH are as follows:

        $P6_INSTALL_PREFIX/languages/nqp/lib
        $P6_INSTALL_PREFIX/languages/nqp/runtime/*
        $P6_INSTALL_PREFIX/languages/perl6/lib
        $P6_INSTALL_PREFIX/languages/perl6/lib/Perl6
        $P6_INSTALL_PREFIX/languages/perl6/runtime
        $P6_INSTALL_PREFIX/languages/perl6/runtime/*
    */
    public RakudoEvalServer() {
        String[] cps = System.getProperty("java.class.path").split("[;:]");
        for(String cfile : cps) {
            if(cfile.endsWith("perl6.jar")) {
                appname = cfile;
                break;
            }
        }
        if(appname == null) {
            throw new RuntimeException("CLASSPATH not set properly, couldn't find perl6.jar");
        }

        System.setProperty("perl6.prefix", appname.substring(0, appname.indexOf("/languages")));
        System.setProperty("perl6.execname", "RakudoEvalServer");
    }
}

@@ -446,33 +446,29 @@
 TALL_PREFIX/
-languages
+share
 /nqp/lib%0A   
@@ -491,25 +491,21 @@
 _PREFIX/
-languages
+share
 /nqp/run
@@ -534,33 +534,29 @@
 TALL_PREFIX/
-languages
+share
 /perl6/lib%0A 
@@ -577,33 +577,29 @@
 TALL_PREFIX/
-languages
+share
 /perl6/lib/P
@@ -626,33 +626,29 @@
 TALL_PREFIX/
-languages
+share
 /perl6/runti
@@ -677,25 +677,21 @@
 _PREFIX/
-languages
+share
 /perl6/r
@@ -1196,17 +1196,13 @@
 f(%22/
-languages
+share
 %22)))

Correct CLASSPATH example