Github user devaraj-kavali commented on the issue:

    https://github.com/apache/spark/pull/18708
  
    Thanks @HyukjinKwon for checking this and for the link.
    
    > Are you saying "file:///C:/Users//.ivy2/jars/.jar" is not the correct 
form of URI on Windows?
    
    This URI form is correct for java.io.File and also for ClassLoader. I see 
that that the jar is getting loaded with this URI form from the ClassLoader 
during my inspection.
    
    SparkSubmit.scala
    
    ```
      private def addJarToClasspath(localJar: String, loader: 
MutableURLClassLoader) {
        val uri = Utils.resolveURI(localJar)
        uri.getScheme match {
          case "file" | "local" =>
            val file = new File(uri.getPath)
            if (file.exists()) {
              loader.addURL(file.toURI.toURL)
            } else {
    ```
    
    
    But this URI form is not supported by the `java -classpath`. In this below 
code, the `jars` are having the `file:///` scheme which is not supported and 
causing the issue.
    
    Main.scala
    
    ```
      private[repl] def doMain(args: Array[String], _interp: SparkILoop): Unit 
= {
        interp = _interp
        val jars = Utils.getUserJars(conf, isShell = 
true).mkString(File.pathSeparator)
        val interpArguments = List(
          "-Yrepl-class-based",
          "-Yrepl-outdir", s"${outputDir.getAbsolutePath}",
          "-classpath", jars
    ```
    
    And also we can see the difference with these java commands,
    
    In Windows,
    ```
    C:\>java -classpath file:///C:/work/test/a1.jar com.test.second.ClassZ
    Error: Could not find or load main class com.test.second.ClassZ
    
    C:\>java -classpath C:/work/test/a1.jar com.test.second.ClassZ
    From main method
    ```
    
    In Unix,
    
    ```
    [devaraj@devaraj-work-pc ~]$ java -classpath 
/home/devaraj/work/install/test/a1.jar com.test.second.ClassZ
    From main method
    
    [devaraj@devaraj-work-pc ~]$ java -classpath 
file:///home/devaraj/work/install/test/a1.jar com.test.second.ClassZ
    From main method
    ```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to