How to execute existing build file in Eclipse using ant command? - java

I am a beginner and new to StackOverflow.
In my root folder, which has a package, I have a build file "build.xml". i wish to execute the build file using the command "ant" while in Eclipse. Example in the folder:
lklk>src>11>"Insert.java","Sort.java","build.xml"
Now, in Terminal we simply type "ant" and the project get's built into jar files.
How do I do the same in Eclipse?
PLEASE NOTE: The answer below maybe right, but the build file isn't showing up there!

window > show view > ant > add build.xml > hit play button

Right-click on the build.xml file. Select: Run As > Ant Build.
Also note, you shouldn't place your build file in the src package. I think build.xml should be the same level as src, not in it.

Related

How do I make an executable file from an intellij idea project?

I created a gradle project in Intellij idea. After building and running everything worked as expected. But I don't want to run an IDE everytime I need to use my program. Can anyone recommend a step-by- step guide?
You can quickly do it in IntelliJ following theses steps :
Go to File > Project Structure
Select Artifacts tab and click on the "+" icon
Choose to generate a JAR from modules with dependencies
Choose your module and its main class and save changes
Now go to Build > build artifacts > build*
It's done, your executable .jar file should be located in out/artifacts/module_name/module.jar
*Choose rebuild if it has already been built.

How to build JAR files from

I am using ColdFusion 2016 and want to use this java library from within ColdFusion.
https://github.com/getstream/stream-java
It is not clear what folders are needed to make this work. I'm very new to doing something specifically like this so please excuse my question if isn't phrased correctly.
I tried downloading the entire zip file from github, renaming it with a .jar extension, and dropping it in my CF classpath but I couldn't seem to instantiate any of the classes.
That's because they're not classes. What you downloaded are the .java source files. Sources must be compiled into *.class files before you can use them. The project is set up for Maven, so you can use an IDE like Eclipse to import the project, then run a Maven build which will compile and create the jar for you.
Download and install Eclipse with JDK 1.8 or higher (not JRE version)
Extract the .zip sources to a folder on disk
In Eclipse, import the project sources.
Select File > Import > Maven > Existing Maven Projects then click Next
Click Browse and navigate to the folder where you extracted the .zip files. Select the root folder stream-java-master and click Select Folder > Finish
Build the jar
Go to Package Explorer, right click the project stream-core and select Run As > Maven Install
Check the console for a success/failure message:
[INFO] BUILD SUCCESS
The compiled jar will be located in a subdirectory named /target. Example:
C:\temp\stream-java-master\stream-core\target\stream-core-2.0.2-SNAPSHOT.jar
If needed, repeat step 4 ("Build a jar") for the other 3 projects.

How to import existing Ant build.xml into IntelliJ IDEA

I have an existing project that uses an Ant build.xml file to maintain the location of dependency jars.
In Eclipse it's very easy to import from an existing Ant file. I have searched online and looked through all of the "new project" options in IntelliJ but cannot figure out how to do this.
The closest thing I've done is File > New > Project from Existing Sources. But my whole project is full of errors because it didn't use the build.xml to include the jars.
Intellij supports Ant projects via built in Ant plugin which is included by default in IDE.
To check if it is enabled go to Settings > Plugins > Ant
After enabling plugin, you can use build.xml from View > Tool Windows > Ant Build
You should then have option(+) of importing your build.xml file.
Import the project "from existing sources" without choosing any build tool (ant is not on the list, only maven, sbt, etc...). Then after completing the import wizard, in the project files view, right click ant's build.xml file, and choose the option relating to ant which is hiding at the bottom of the menu.
You should use File > New > Module instead of File > New > Project from Existing Sources for Ant project. You also need to set your Content root and Module file location to your current Ant project directory.
You may also need to set right path to project output in Project Structure > Use module compile output path and set proper content route in Project Structure > Sources
Please, follow the steps below if you use the IntellIj:
Check the Ant plugin for the project.
select the build.xml file and add as the Ant build file
Use the side button to deploy the project

Error when using Jsoup in Eclipse

I downloaded the .jar Jsoup file from jsoup.org/download. I then ran eclipse and imported the .jar files into a java project. However, I keep getting an error when I type
import org.jsoup.nodes.*;
I want to use the Document class in that file.
I made sure the syntax was correct and everything, but the error won't go away. Anyone know what the problem could be?
You need to add the JAR file to project's build path. Drop the JAR in the project's root folder or some /lib folder, rightclick the JAR file and then choose Build Path > Add to Build Path.
Unrelated to the concrete problem, using wildcard imports is not the best practice. Rather specify the imports separately, or just let Eclipse autocomplete it by entering Ctrl+Space after typing Document in the code.
Right click on project in Eclipse > Properties > Java Build Path > Add Jar > select the jar from your project which you imported before > ok

Creating and using custom JAR in Android project

I am trying to create and use jar file in an Android project under Eclipse. I have tried various methods without any success. Here are the steps:
Create jar file from the source files jar -cf lib.jar *.java
Copy jar file to libs folder
Right click, Build Path->Add to Build path
Now, compiler gives unresolved symbols if I try to use a class from the jar file?
Can someone please let me know correct method to create and use an external jar file for the Android project under eclipse.
This worked fine for me:
1)Place Jars in assets folder.
2)Right click on project name.
3)Select properties.
4)Select Java build path.
5) Select Libraries.
6) Click Add Jars.

Categories