build paths eclipse java j2ee - eclipse

I have imported a project (I am very new at this) and I get the following errors:
Project cannot be built until build path errors are resolved
Project FST is missing required library: 'C:program Files/Apache Group/Tomcat 4.1/common/lib/servlet.jar'
Project FST is missing required library: 'C:program Files/Apache Group/Tomcat 4.1/common/lib/struts.jar'
The project cannot be built until build path errors are resolved
Unbound classpath variable: 'TOMCAT_HOME/common/lib/jasper-runtime.jar' in project
Unbound classpath variable: 'TOMCAT_HOME' in project FST
I create a variable called TOMCAT_HOME and give it the proper directory ,but Also, we should change the project classpath to use TOMCAT_HOME rather than the absolute path.
i dont know how to do it (change the project classpath and the absolute path)
thanks !

To answer somewhat indirectly, if you configure your project build with something like Maven or Gradle, so that you can successfully build the project using the corresponding command-line tool, then it should be quite straightforward to import the project into eclipse using the Maven or Gradle eclipse plugin. I think doing so will be worth whatever trouble it causes you in the short run--just take care to make your project structure conform to the usual project structure that Maven expects or you'll be asking for trouble (it should be no problem to do so for greenfield work).

Related

Chisel: Compiling Chisel library on Windows

I have been using sbt on windows and a custom build.sbt script in conjunction with an import Chisel._ in the top-level file in order to generate Verilog from my Chisel source successfully.
I'm trying to get an IDE working on Windows to expedite Chisel development. I've gone with the Eclipse based SCALA IDE http://scala-ide.org/download/sdk.html/
I want to compile the Chisel library so that the import Chisel._ can be resolved locally, without having to go off and download the source from the repository each timeand recompile the source. When I download the Chisel-master repo from Git and include the src\main folder in my SCALA project in the SCALA IDE, I get lots of syntax errors in the Chisel SCALA files that prevent me from building the project.
Has anyone done anything like this before on Windows or have any knowledge of working with the SCALA IDE as it may just be a case of undefined symbols in the project configuration?
Not sure exactly what you did with build.sbt respect to recompile (I think it download it only the first time, then it caches it for the future). But I'm using ScalaIDE for Chisel on linux, using the default build.sbt files, maybe you can try to get it working out of the box first to help narrow down the issue.
Here are the steps I took in order to get ScalaIDE work with Chisel:
the latest Scala IDE uses 2.11.8, the current Chisel repository defaults to 2.11.7. So I had to change all the build.sbt reference to scalaVersion from 2.11.7 to 2.11.8
I used sbteclipse
https://github.com/typesafehub/sbteclipse
To create importable the workspace to setup the compilation dependencies.
Except for chiselFrontEnd. For some reason, this package is not added to the dependency. I have to Add chiselFrontEnd as a javabuildpath dependency manually (Properties/JavaBuildPath, under Projects) for my own projects.
To resolve undefined symbols, you can also add a JAR onto the project build path using Project Properties > Java Build Path > Libraries > Add External JARs...
If you are getting your JARs through Maven / SBT, they should be in:
C:\Users\<name>\.ivy2\local\edu.berkeley.cs\chisel3_2.11\jars
If you are using publish-local with chisel3, your JARs should be in
C:\Users\<name>\.ivy2\cache\edu.berkeley.cs\chisel3_2.11\jars
Note that chisel3 is compiled into one JAR, including coreMacros and chiselFrontend sub-projects
Of course, this is a more quick-and-dirty solution compared to something that can parse SBT files.

sbt dependency root catalog differs from intellij libraries after import

I'm using Scala plugin version 1.3.3 for Intellij 14.0.3 at my work computer and have started a new SBT project from scratch without any hassle.
But my problems starts right here where build.sbt file have compile errors in Intellij, it can not resolve any line of code. I can how ever auto import by changing the build.sbt file and adding a library dependencies..
So I tested to add scalatest which is downloaded to an .ivy2 directory, but a totaly different one that Intellij are using.
This is how ever how my project structure are looking like, every libs have an error due to wrong path.
And here is where SBT plugin is locating all of it's dependencies and scala libs.
I know how to change where .ivy2 directory will be stored by adding these two parameters to
Settings -> Build,Execution, Deployment -> Build Tools -> SBT -> JVM Options -> VM parameters
-Dsbt.ivy.home=c:/.ivy2
-Dsbt.home=c:/.ivy2
But it only works for .iv2 folders and not the .sbt folders that are also in the wrong place. I believe that's the cause of why I can't resolve the symbols in the build.sbt script.
Does anyone know why this is happening and how I just can have one directory for both Scala plugin and Itellij project files?

sbteclipse not adding generated source folders to java build path?

I ran sbt eclipse on a Scala Project and when I imported it into Scala IDE(4.0.0 RC2), it gave me a type not found error as the types referred to were actually auto-generated code which were at target/scala-2_10/src_managed/main/compiled_avro/org/... I was able to do a sbt compile at the console though.
I got it to compile by adding the above folder to the Java Build Path.
My question is that since sbt eclipse can already detect Java Projects which the current project depends on and since sbt compile works at the console, should sbt eclipse be able to figure out dependencies to source folders of generated code as well? or maybe such a feature exists and I just don't know about it?
This may not be the correct way of doing things but to fix the issue i did the following.
sbt avro:compile
sbt compile
sbt eclipse
In eclipse i right clicked on target/scala-*/src_managed/main/compiled_avro > build path > use as source folder
The sbteclipse way:
Edit your project or global build.sbt file. My global ~/.sbt/0.13/build.sbt contains:
import com.typesafe.sbteclipse.plugin.EclipsePlugin._
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Managed
I'm using an older version of _sbteclipse, version 2.5.0 (various non-relevant reasons), which seems to require both the import and a single blank link between each line of real content (this drives me a bit crazy, yes). I don't believe the import is required for newer versions of sbteclipse.
sbt clean avro:compile compile
sbt eclipse

Intellij unable to resolve references to a specific jar file

In a given project that is driven by sbt there is some kind of corruption in the project libraries specifically for a MavenLocal repository used for kafka-spark-9.7.2.jar in which:
references to the classes provided by that jar are marked as "symbol not found" by the editor parser
however the editor (strangely) does offer to import the classes
but after accepting the import, the symbols are still marked in red as unresolved.
The following attempts to "clean things up" have already been performed:
Build | Make Project
Build | Rebuild Project
In addition I have verified that the project does build from
sbt package
on the command line
UPDATE After re-running sbt gen-idea the librraries are still not found by the Parser. yet the libraries exist -even IJ knows about them as shown in the following screenshot. Why is it that IJ can find the library
C:\Users\S80035683\.ivy2\cache\org.apache.kafka\kafka\jars\kafka-0.7.2-spark.jar!\kafka\api\FetchRequest.class
However IJ is unable to resolve any classes from that library in the Parser?
You have to build the project for Intellij, try to do this in your project root:
sbt idea with-sources=yes
This should build the project structure from scratch and add the right dependencies, usually I refresh the project after adding a dependency or a jar.
Edit:
To use the command you need this plugin, otherwise you can use gen-idea but I used it only a few times and I'm not sure how it will work out.
Edit2:
There was some confusion, first, for the IDEA SBT console you don't need to prepend the sbt command since you already are inside sbt:
If you have the sbt plugin for idea you can use gen-idea with-source=yes (without prepending sbt)
From the terminal, either you go to your project root and type sbt to enter the sbt console and use gen-idea or idea with-sources=yes (without prepending sbt)
or directly sbt gen-idea or if you have the plugin sbt idea with-sources=yes (prepending sbt)
To reach the sbt console inside idea you need to install the sbt plugin on preferences -> plugin and search for sbt and then View -> Tool Windows -> SBT Console:
To start the console click on the play button, to kill the console on the skull.
I had the same problem. I fixed it by directly writing the CLASSES and SOURCES of the problematic library. This can be found in .idea/libraries/SBT__<problematic library>_jar.xml

Unable to make IntelliJ Idea 12 work with Scala compiler

I have installed Scala, sbt, eclipse and IntelliJ Idea 12. And also jdk, jre, etc. I'm able to run scala in Eclipse (Scala eclipse IDE) but I can't do it in Idea, even though I downloaded and installed scala plugin though Idea. Here is what I'm having at File -> Setting
and at a new project creation page
How do I solve these issues?
whereis scala
scala: /usr/bin/scala /usr/bin/X11/scala /usr/share/scala
which scala
/usr/bin/scala
I know I'm repeating this at any possible occasion—but your life will be much easier if you have sbt generate your IDEA project instead of trying to set it up manually. That will take care of configuring the modules correctly, so you are instantly ready to compile and run.
Here is a blog entry that might help. The section "How can I integrate libraries installed by SBT to IDEA?" tells you how to generate the project files.
Basically you need to create—starting from the root directory of your project—the file project/plugins.sbt with the following content:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")
(you can also do that in the file ~/.sbt/plugins/build.sbt instead, that way you have the plugin available for any of your projects)
Then you run sbt gen-idea, and afterwards you can open the project directly from IDEA through File -> Open Project (and pointing to the project's root directory).
You could also generate your IDEA project with Gradle, which handles Scala+IDEA combination very well. Here's a minimal build.gradle script to do this:
apply plugin: 'scala'
apply plugin: 'idea'
repositories {
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.10.1'
}
Just create a directory for your project, put build.gradle inside it, create src/main/scala subdirectory, then install Gradle and run gradle idea inside your project's directory. That should generate nicely configured IDEA project. With this method you don't even need to install Scala.
What exactly your problem is? I don't see anything on your screens which prevents you from using Scala in IDEA. Just select "Set Scala Home" radiobutton in "New project" dialog and then select your Scala installation path (I guess it will be /usr/share/scala). IDEA then will automatically create library and compiler libraries and add Scala facet to your project.