I am quite new to Java, although I worked with some projects. I use IntelliJ IDEA, and I have issue with my web project.
Whenever I RUN the project from IntelliJ and when it's made and built - my localizations texts are not shown, but everything is ok if I use mvn install and deploy the war file manually.
What I found is that jars built with IntelliJ don't have MANIFEST.MF generated and couple of other files.
This is IntelliJ jar
This is jar when I run mvn install from console:
Can somebody help with this, why this happens? I have same maven used for compiling as I use for console run:
If you have a Maven project, then you can choose one on the tasks on the right of the editor.
jar or package should generate a JAR file.
Maven is a software tool that helps manage a project and automate builds. By default, however you have to select Maven as the desired type of project when you go to create a new project.
Basically, create a Maven project! :)
Related
I used Maven to generate a Jersey project from command line, and I also used mvn eclipse:eclipse so that I can import my project to eclipse.
After I opened the project from Eclipse I see all the jars were in the root folder, how do I create a folder or package so that I can move all these jars into it?
Don't use mvn eclipse:eclipse.
Just do File -> Import -> Maven -> Existing Maven projects and browse the folder where your pom.xml is and Eclipse will organize everything for you.
It looks like you aren't using Maven eclipse integration - m2eclipse. You shouldn't have to install it, it comes already with more recent versions of Eclipse, though follow the instructions in that link if you don't yet have it.
If you just generated the project, try deleting it and then generating it again inside eclipse with New -> Other -> Maven Project. If you have a lot of code written already, instead right click on the project and do Configure -> Convert to Maven Project. Once you've done that, you may have to do Maven -> Update Project project to straighten out your jars, and possibly remove them manually with Build Path -> Configure Build Path.
However, I recommend creating the project from within Eclipse, if possible.
Addendum: #cahen's answer is also correct; don't use mvn eclipse:eclipse.
why do I need to apply: mvn eclipse:eclipse command?
are they equivalent to application container/server?
Is there a file for which customizing is necessary besides web.xml?
when you create a web project using maven, like maven-archetype-webapp. It creates the folder structure as recommend by Maven for a webapp like shown here .
Now when you try to import these folders in Eclipse, it still would look like folders but eclipse cannot understand the nature of these folders. Eclipse relates folders and contents within them to an Eclipse dynamic web project only through its .project , .settings files
So in order for your maven project to be understood by Eclipse, you run the goal mvn eclipse:eclipse. After executing this goal, maven generates the .project, .settings files necessary for eclipse to understand the project as Web project.
This is however optional. You can still import the project as Maven projects within eclipse and continue to use them but you cant rely on Eclipse's features like clean/ build / build automatically.
Though I use eclipse, I dont rely on Eclipse's build feature. I have installed Maven eclipse plugin and that allows me to run maven goals and commands within Eclipse which is as good as running Eclipse's build feature. Hope this helps.
I have a jar codebase (developed and successfully compiled in Intellij IDEA) without class files. I want to make jar with that codebase through windows batch-script only. Please help me to make the jar automatically without opening it in any IDE or any manual operation.
Thanks in advance for the help.
You generally do that using build tools like Ant, Maven. Maven is quite more popular these days.
Convert your intellij project into an Maven project like this (IntelliJ - Convert a Java project/module into a Maven project/module), and then execute call mvn clean package from your windows script to build the jar. The jar will be located under ${project.dir}/target
I imported a Maven project into Eclipse. I was able to deploy it from the command line. In Eclipse it is full of red Xs. I have cleaned the project, updated the configuration and I ran the following command:
mvn -Declipse.workspace=<pathtoworksapce> eclipse:add-maven-repo
and I still have the same problem. The project is dependent on another project.
What I ended up doing was removing all of the projects in Eclipse, but not deleting the source files. Then instead of directly importing the code as Maven->Check out as Maven Projects with SCM, I selected Existing Maven Project and imported the code from my local machine. This got rid of the errors, but when I would right click on code and select "Open Declaration", I would get Error: Could not open the editor: The file does not exist" So I removed all projects again and this time I deleted all the ".project" files and repeated the import Existing Maven Project. So now there are no red Xs (dependency problems) and the lookup functionality within the code works.
Go to your master project and type the following :
mvn install
mvn eclipse:eclipse
After that, import your project. You can also install m2eclipse for better support. If you use gwt or any other framework which has a custom maven execution, you should also install plugins for those in Eclipse.
I have two maven projects and both are working fine independently. I am able to create a jar file and run it from console as well as from eclipse.
I copied over some classes from the second project into the first and made a few changes so that it runs as a single project with features from both.
I have two pom files, so I combined them into a single pom file.
The thing is that I am able to run it from eclipse fine and able to get the output I was hoping for.
But I am not able to run it after executing the jar file created from "mvn package".
I am using shade maven plugin.
If I use maven build.. with clean install as goal, it again showing errors.
My question is this, why this discrepancy?
We would need more information to correctly diagnose the issue. One thing to look at is to ensure that any changes to dependencies which are projects in Eclipse have been installed as a command line build will only look in your repo, not at your Eclipse project.
This may happen when you have a dependency which exists as an open project in your eclipse workspace.
Try closing every project except the one where you're having this problem. Does it still compile in eclipse then?