Eclipse's Ant needs jsch - eclipse

I run ant script file in my Eclipse IDE. File contains command scp:
<scp file="myfile.txt" todir="user:password#somehost:/home/chuck"/>
This line causes error:
Cause: Could not load a dependent class com/jcraft/jsch/Logger
It is not enough to have Ant's optional JARs
Why my Eclipse's Ant does not have this class and where I can download requied library? How to know which library version is needed?

You can have a look here for JSCH http://www.jcraft.com/jsch/
There is a Download section where you can find a .jar (jsch-0.1.54.jar at time of writing).
Then you have to setup ANT buildpath to use this jar.

Related

Cannot find parser that supports .groovy

When I'm trying to start changelog.groovy via liquibase command line it tells me that
Unexpected error running Liquibase: Cannot find parser that supports changelog.groovy
I'm doing the next: java -jar liquibase.jar update
My liquibase.properties are:
driver=org.postgresql.Driver
classpath=C:\Users\Andrii\org.postgresql.Driver.jar;C:\Users\Andrii\liquibase-3.5.1-bin\lib\liquibase-groovy-dsl-1.2.2-SNAPSHOT.jar
changeLogFile=D:\changelog.groovy
url=jdbc:postgresql://localhost:5432/test
username=postgres
password=rup
It finds those jars since if I change something in that path it will tell that jars cannot be found.
I downloaded the groovy-liquibase-dsl project, build it and added a jar into classpath. What am I doing wrong?
To make it work, you need to additionally include groovy and groovy-sql jars in Liquibase's classpath.
So say you store all the jars in C:\Users\Andrii\LiquibaseDependencies, update your the classpath property of your file as such:
classpath=C:\Users\Andrii\LiquibaseDependencies\org.postgresql.Driver.jar;
C:\Users\Andrii\LiquibaseDependencies\liquibase-groovy-dsl-1.2.1.jar;
C:\Users\Andrii\LiquibaseDependencies\groovy-2.4.6.jar;
C:\Users\Andrii\LiquibaseDependencies\groovy-sql-2.4.6.jar

build paths eclipse java j2ee

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).

How to generate an eclipse project from a maven pom file for the compilation target only?

I want to generate an eclipse project from a pom file that will ignore resources (code and libraries) that are not required for the compilation (like tests resources...)
Oh, and I can't modify the original pom file.
For now now, I use:
mvn org.apache.maven.plugins:maven-eclipse-plugin:eclipse
And I get a project with the test sources and dependencies included.
Is there some parameter or config file that I can pass to that command to exclude the unwanted stuff?
Update I don't want to have to use m2eor change my eclipse configuration.

Gradle / Eclipse

I have a gradle project in eclipse (using STS plugin). I have a properties file I want on my classpath. This file is read during tests. In my project view, I put this file on
\src\test\resources\test.properties
When I run
gradle test
from the command line, this file is read.
But when I run eclipse it is not.
To reiterate what superEb said in his comment:
src/test/resources must be designated as a source folder for Eclipse to include your properties file on the classpath for tests.
You can in include Gradle's Eclipse plugin to handle this for you automatically with:
apply plugin: 'eclipse'

Why won't Eclipse compile my code in java 1.5?

I have installed Eclipse 3.5.2 and the JDK for Java 6.
Here's my installed JREs in Eclipse
alt text http://img806.imageshack.us/img806/3345/eclipsejres.jpg
I am trying to compile with an ant build file, part of which looks like this and specifies java 1.5:
<target name="compile" depends="build-common, init" description="Compile files. ">
<javac srcdir="${src_dir}" destdir="${build_dir}" debug="true" target="1.5" source="1.5">
<classpath path="${tomcat_home}/lib/servlet-api.jar;${tomcat_home}/lib/log4j-1.2.15.jar;/usr/local/lib/portlet-api-1.0.jar;." />
</javac>
</target>
But when I try to compile, the console window displays the following error:
compile:
[javac] Compiling 1 source file to H:\jephperro\portlets\build
[javac] javac: invalid target release: 1.5
[javac] Usage: javac <options> <source files>
[javac] where possible options include:
[javac] -g Generate all debugging info
[javac] -g:none Generate no debugging info
[javac] -g:{lines,vars,source} Generate only some debugging info
[javac] -nowarn Generate no warnings
[javac] -verbose ....
BUILD FAILED
H:\jephperro\portlets\CourseList-build.xml:25: Compile failed; see the compiler error output for details.
Total time: 531 milliseconds
What's my problem with Eclipse?
see the compiler error output for details.
You probably have a dependency on a library that was compiled using a later version of Java than your 1.5 JDK.
Actually, where is your 1.5 JDK? All I see is a JRE. My guess is that you just need to download a version 1.5 JDK and add that in Eclipse.
You could create a task in your ant build file that runs the equivalent of java -version so you'll get an idea of which Java compiler is being used by the ant that's started up by Eclipse.
Hint: Your default JRE is a 1.6 JRE. That's fine for running code, but not for compiling. Only a JDK contains the magic required by an external compile (such as done by ant). Eclipse gets around this by including an incremental Java compiler in its own code (more magic).
After years, I still don't fully understand how Eclipse, ant and the JDK interoperate, so maybe you need to do a little experimenting.
AFAIR Eclipse does not use its own internal Java compiler when an Ant file is run. Check your local paths and try to find out which javac is called by Ant.
The 'javac: invalid target release: 1.5' Compilation error is commonly caused by source/binary level incompatibility. Meaning you are trying to compile a source level of JDK 5 with a JDK 1.4 or less.
Eclipse uses a built-in Java compiler. The level actually followed by the compiler depends on the project settings. You can configure the Java level per project or set it as a default at a global level.
From the menu bar, select Window->Preferences. Select the Java->Compiler preference. Set the Compiler Compliance level to 5.0.
As Saifuddin and others mentioned this error is most likely the cause of not using the right Java compiler for the version you want. I notice in your installed JRE's there is a JDK located in DevsuiteHome_1, doesn't say what version. Maybe Ant is using that?
It is very easy to check. You are running ant within Eclipse. Ant has it's own configuration settings that can be different to your workspace. To check the version Ant is using when it runs follow these steps:
Run -> External Tools -> External Tools Configuration -> click on your ant build file (should be created if you ran it once already if not you could always create it here) -> select the JRE Tab -> Verify the runtime you are using