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.
Related
I have some problems while creating a jar of my intelliJ project. First of all I just do the usual procedure:
Go to project structure
Select artifacts
Create a new one with modules and dependecies
Go to build artifact, build it
Execute it at console with java -jar "ddddd.jar"
So when I execute the project (not the jar) all runs ok, libreries and all works, but not in the JAR.
Terminal of IntelliJ:
My libraries are located in the project like: project>lib>"some jars here">otherjars>"here some jars and respective dll
This is because the "other jars" need the dll to work. I already tried to run them without the .dll but doesn't work without it.
Also I have them in the project on Modules>Dependencies I have the folder selected as a library.
Any help would be appreciated.
Edit 1:
Here I add some pictures about how I have my libraries structured.
I imported a git folder https://github.com/TeamLapen/Vampirism.git ((If you were wondering)). And so now I have it within my eclipse workspace, but not "really". Here's what I mean: The project shows up in the tree on the left of the eclipse window, but the folder itsself is NOT located in the /workspace/ like the other projects.
All I did in the code was change a few lines to fix a bug, as is highlighted below.
Anyways, when I go to export the file (File > Export > Jar), a few things happen:
In the box on the left, you see the project name is "Vampirismx". In the middle box, you see that the project is NOT AVAILABLE FOR EXPORT. In the right box, you see the only files "available" for export are the classpath and project files.
Can someone help me?
Tl;dr
I imported an eclipse project from git. When trying to export it, the project isn't showing up.
looking at the git repository, it does not provide eclipse project settings, and indicates only step by step instructions for intelliJ.
So when you imported it into eclipse, you have it on your workspace like a plain project, not a java one and that is why trying to export it as JAR does not shows up.
You must indicates that the project is a java project and it should work.
also, i'm not familiar with gradle, but seams there is a goal for settings things in eclipse : https://github.com/TeamLapen/Vampirism#setting-up-vampirism-in-another-environment
I have the following Java program in Intellij and I cant seem to figure out how to run the program from my mac terminal (or export everything to run it on a different computer). Currently the only way I can run the program is if I press RUN in the IDE. I assume I need a .jar file but where do I go to compile that? Any help would be greatly appreciated.
Open your project settings in the upper right corner (or ctrl+alt+shift+s) and go to "Artifacts". Then add Jar -> From modules with dependencies
Choose your Module and your Main-class and Submit and apply the project settings
After that you can go to Build -> Build Artifacts -> Build
IntelliJ creates the jar inside the "out" folder in your project folder.
(This is for simple Projects. If your project is a bit more complex, you might need more settings.)
#MadProgrammer: Before packaging a Java module into a JAR file, you need to configure an artifact of the type JAR. This artifact can define the output of one or more modules
Once I added the artifact and then build the artifact I am able to run the program via terminal
This is probably a basic question for you here but here goes:
I'm building a java project using Maven in eclipse at the moment. I have a pom.xml file which is working fine, but I need to be able to organise my source files into 'src/main/java' and resources into 'src/main/resources' etc. Any other maven projects I've looked at are structured like this and the build goes to success without picking up any source files, since it "skips non existent resourceDirectory src/main/resources" and the others.
I currently have a source folder 'src', and eclipse won't let me add more source folders with 'src' in the name.
Any guidance whatsoever would be greatly appreciated.
Try right-clicking on the project and selecting Maven->Update Project Configuration from the context menu. Then refresh the project. If your pom is close to right, that should represent your project in eclipse the way you want.
Why don't you just open your pom.xml file in eclipse? It can recognize it and will built its project files correspondingly
In eclipse right click over the project / Build Path / Configure Build Path / Source (tab)/ Add folder and select the source folder you want. If the folder you need doesn't exist under /src/main create it following the maven conventions.
after that I would recommend:
mvn eclipse:clean eclipse:eclipse
I'm debugging my application and I see that I have an exception in jar file which is built from completely separate Java project. I checked out this project from SVN.
How can I attach this project in Eclipse to my current project and debug this code as well?
You'll have to create a dependency of one project on the other.
Right Click on your project name > Properties > Java Build Path > Projects
Just make sure that both projects are in the same workspace.