Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why IDEA can't recognize the Spark jar file?

I've downloaded the source code of Spark, extract it and build it according to the official document as follows:

wget http://ftp.tc.edu.tw/pub/Apache/spark/spark-1.2.0/spark-1.2.0.tgz .
tar xzf spark-1.2.0.tgz
cd spark-1.2.0
mvn -Pyarn -Phadoop-2.2 -Dscala-2.11 -DskipTests clean package

Finally I transfer the assembly jar file to local:

scp root@host:/home/workspace/spark-1.2.0/assembly/target/scala-2.11/spark-assembly-1.2.0-hadoop2.2.0.jar ~

I intend to import this jar file into my project in Intellij Idea, but this jar cannot be recognized by the IDE, and an error has be thrown: 'IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list.', which is shown in the following graph:

Error when import jar in Intellij Idea

The bad thing is that there are many grammar error in my edit windows which are all related to Spark package and Hadoop package, whereas the project can build successfully in this scenario regardless of the grammar error mentioned above.

P.S.

  1. I'm 100% sure that some of my other jar files (e.g. in .m2 directory) can be imported normally without the aforementioned error/warning.

  2. If I import the same jar file into Eclipse, it is recognized successfully. I've tested this jar both in IDEA-13 and IDEA-14, which all fails.

  3. Viewing the content of this jar via jar -tf XXX.jar works normally.

  4. After adding this problematic .jar file into my project, I can't even view the content of the jar file. cant_view_jar_content

    This is what a normal .jar file looks like: normal_jar_file

I've uploaded this jar in BaiDu_YunFile, Could anyone give me some idea? Thanks a lot!

like image 398
Judking Avatar asked Feb 04 '15 09:02

Judking


People also ask

How do I add a jar to spark shell?

You can also add jars using Spark submit option --jar , using this option you can add a single jar or multiple jars by comma-separated.


1 Answers

Check the jdk version (Perfrence-->About Intellij IDEA) which the Intellij IDEA used. If the version is too low, it cannot parse the jar properly. If you use the mac IDEA, just update the jvm version to 1.7 or newer in the info.plist of the IDEA contents folder.

like image 181
Zachary Avatar answered Nov 01 '22 18:11

Zachary