eclipse怎么用java写spark,在ubuntu之下使用eclipse和java开发Spark应用的方法

It is assumed that you have installed java JDK.  I am currently using JDK 1.7

Download the Eclipse luna and untar it to an /opt/ directory as a sudo

cd /opt/ && sudo tar -zxvf ~/Downloads/eclipse-*.tar.gz

Then, to add a shortcut, create a new file

sudo gedit /usr/share/applications/eclipse.desktop

in gedit, write the following lines, save and exit:

[Desktop Entry]

Name=Eclipse 4

Type=Application

Exec=/opt/eclipse/eclipse

Terminal=false

Icon=/opt/eclipse/icon.xpm

Comment=Integrated Development Environment

NoDisplay=false

Categories=Development;IDE;

Name[en]=Eclipse

Open eclipse under applications->programming.

When done, create a new Maven project by doing:

File->new->Project

Under Maven dropdown, select “Maven Project” then click on Next.

Select:

Create simple project ….

Use Default Workspace….

Click Next

Select ANYTHING for a groupID and ArtifactID then press FInish

Then go to a Project Explorer

Click on the root (name) of the project

Go to help->install new software->add…

The URL is  http://download.scala-ide.org/sdk/lithium/e44/scala211/stable/site

For name use anything (Scala)

Select all suggestions and install them.

Under Package Explorer, double-click on the pom.xml

Locate the Dependencies tab and click on it

Click on Add… under the Dependencies and type

groupId: org.apache.spark

artifactId: spark-core_2.10

version: 1.2.0

Save and close the POM file’s tab.

in Package explorer, right click on src/main/java and select new class.

Make a new class with a main, you can call it  NewClass

Copy and paste the code below

import org.apache.spark.SparkConf ;

import org.apache.spark.api.java.JavaSparkContext;

public class NewClass {

public static void main(String[]args){

SparkConf conf = new SparkConf (). setMaster ( “local” ). setAppName ( “My App” );

JavaSparkContext sc = new JavaSparkContext ( conf );

}

}

Press run, the project will build and run

IF YOU GET AN ERROR:

Exception in thread “main” java.lang.NoClassDefFoundError: scala/Cloneable…

just import the  Maven project from below (sorry):

https://drive.google.com/file/d/0B7egWfChXyoebTlvRHFiNUMzZWc/view?usp=sharing

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值