IntelliJ download the libraries once and use in multiple projects - scala

I have an IntelliJ with Scala plugin intalled on the server. The server is disconnected from the global internet and all the updates can be done ocsasionally only.
Would like to download some libraries once (e.g. Spark libraries, some libraries from Java) and use them in IntelliJ in the multiple projects without need of downloading them, but loading from local direcories. Also it would be great to have a 'full' bundle of libraries (e.g. all Spark libraries) and be able to use only particular classes when it's necessary (e.g. Spark Context only).
TK
P.S. Question is somewhat related to the: Use Scala on computer without internet connection

As #MarioGalic sugested, the cluse was to move a required libraries to the ~/.ivy2 directory.
Somethimes the case is to add libraries manually in IntelliJ project setup, insted of using SBT or Maven to manage the dependencies.

Related

outside lib in GitHub

I just recently used Github, and when I was trying to upload my java project I realized that I was using some external libraries like apahce poi in this project, and these files have to be stored in libs for my application to function, do I need to upload these files because I realize that might violate some issues(maybe ?).
If yes, then what is the correct way to upload or maybe just post a link to those dependency
Use a tool that provides a dependency management system such as Maven or Gradle (these are both common choices in the Java ecosystem). Your project will then include a configuration file that Maven or Gradle will use to download dependencies so you don't need to distribute them with your project.

How does sbt integrate with IntelliJ?

Is there a definite doc somewhere that explains all the magic that happens behind the "Typesafe Activator" generation of "IntelliJ supported" project?
The sbt build files look absolutely monstrous, and I have no idea what and where IntelliJ looks for.
This is frustrating as working from two different PCs the scala seed project refers to different hard-coded paths.
Is there a good place to start?
Last time I checked, the typesafe activator was using SBT as the underlying build tool. When creating an intellij project it would thus use the sbt-idea plugin.
I guess a possible place to start would be that plugin's documentation.
However I think there is something else going on here. I think you have the activator installed on two different PCs and are trying to share the project between both PCs whether using version control or copying the folders.
The sbt-idea plugin will indeed write some absolute path in ideas project files (most likely the absolute paths to the sbt managed libraries in the ivy cache of your home folder) since this is required for the intellij project to work.
There should be no reason to "share" the idea project files, these should be considered computer specific and should not be checked into source control, or expected to work when copied from a random computer to another. You are expected to regenerate them for each computer the project is worked on.
If that sounds like a burden, you may want to install the Intellij scala plugin. Once installed, the sbt integration will allow you to import any sbt project even if you haven't generated the intellij support in the activator. Have a look at the features page, there is a video showing how to use the plugin.

eclipse: rebuild a project and all libraries

I'm creating a Java project which includes a few libraries written by myself. However these libraries are not finished and sometimes require some edits. Because I'm working by myself, I find this more efficient than finishing all libraries perfectly before using them in my project.
My question is: is it possible to automatically rebuild a modified library when building the project which uses it?
Subquestion: what is the optimal configuration for my purposes? Should I export libraries as jar and copy them into the final project or should I configure buildpaths of my project to retrieve them in their respective folders?
Subsubquestion: is it correct to use .jar libraries in the same way that one uses dynamic libraries in c++?
If you have Eclipse set to "build automatically", it'll take care of rebuilding the library projects whenever you make changes, as you go along. You should set your client program to depend on either the Eclipse projects (if doing everything inside Eclipse) or the Maven artifacts (if using m2e). I strongly prefer using Maven for all my Java builds, but it might be overkill for something small. Whatever you do, don't manually export and reimport the libraries.
All libraries in Java are dynamic, and a C++ .so or .dll is the basic equivalent.

Running Simple Hadoop Programs On Eclipse

I am pretty new to hadoop & ubuntu so please bear with me. I find it very inconvenient to compile my hadoop .java files from command line. So I have created an eclipse project & imported all the hadoop libraries so that the eclipse does not throw any reference errors. And it does not. However when I run the files as a standalone java application I get the following error
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
I am running on ubuntu and I have researched this problem elsewhere on web. I do not expect to see this error since the only difference is that I am running it within eclipse and not from command line. Where I am going wrong. Is there a specific way in which I need to add hadoop dependencies to my hello world hadoop projects? Will a simple buildpath configuration and importing of the necessary libraries not suffice? Appreciate all your responses.
you can try right-clicking the Project, ->Build Path -> Configure Build Path
Go to your src folder, point to "Native Library", then edit the location to the location of your hadoop native library folder (normally: ~/hadoop-x.x.x/lib/native/"folder-depending-on-your-system")
It is a warning and not an error which tells you that there is some problem in loading the native libraries which Hadoop makes use of. It should not have any negative impact on your job's output though. Remember Hadoop has native implementations of certain components for performance reasons and for non-availability of Java implementations. On the *nix platforms the library is named libhadoop.so. Using Eclipse doesn't make any difference the way Hadoop works. It's just that your Eclipse is unable to load the native libraries due to some reasons.
One possible reason might be that there is some problem with your java.library.path. You can configure Eclipse to load the proper libraries by configuring the build path as per your environment. To know more about Hadoop's native libraries, and how to build and use them you can visit this link.

How to add new JVM languages e.g. Scala, Clojure, Fantom, Groovy to Eclipse IDE?

What's a prefereed way to download Scala , via scala-lang.org, can it be added directly by the Eclipse IDE or how to add Scala to Eclipse IDE? Is there a convention on how to add a JVM language?
Update
I could add Clojure and Scala from Help...install new software so now I can create those kinds of projects:
You typically install a plugin for that language using Eclipse's build in plugin language.
for instance for Clojure you can search the plugin manager for "counter clockwise" to get Clojure support. for Scala it looks like http://scala-ide.org/ is a good starting point for detailed instructions and a nice screencast on setting this up. It's worth noting that many JVM languages like Clojure don't need to be explicitly installed, they are downloaded as required by standard Java build tools like Maven. Other languages like Groovy are more easily used if you install them explicity.
If you're an IDEA user, by far the best way is to use SBT to manage your projects and use its sbt-idea plug-in (which adds the gen-idea task) to create IDEA projects files and directories.
Ideally, use Paul Phillips' SBT launcher (to get SBT version flexibility if you're ever going to build 3rd-party projects whose specified SBT versions can be all over the map) and configure non-project-specific plugins, such as sbt-idea, in your per-user shared ~/.sbt directory. That way all your projects have it automatically yet it does not intrude on the project definition itself.
Optionally, there is an IDEA plug-in that integrates SBT's interactive console with the IDEA app. The best part of that is compilation errors become hyperlinks to your code.
I don't know if there's an Eclipse counterpart to sbt-idea, but even if there's not, SBT is the way to go.
The JVM languages typically have plugins for Eclipse, e.g. Counterclockwise for Clojure.
In many cases you can also use JVM languages without a plugin in a regular Java project. For example the following approach works with Clojure:
Include clojure-1.4.0.jar as a dependency (using Maven or similar)
Include clojure source files as regular resources in your project
Write a short piece of Java code that executes the clojure code by calling the appropriate methods in clojure.lang.RT (a class provided in Clojure's jar file)