I have a very large maven project, and when I'm debugging, it sucks to have to rebuild the entire project just to see the changes. My current method is to compile the java file in IntelliJ, then copy the class file in my target directory, to my tomcat/webapps/project/ directory, and replace the existing class file with the intellij compiled class file. Then rebuild the war file, and replace it with the existing war file in the tomcat/webapps directory.
I want to be able to automate this process. I looked into doing it with the javac command, but I'm having problems with packages be imported from jar files in the .m2 directory, and can't figure out how to automate the classpath, depending on the specific file. I'm sure IntelliJ does this automatically, and was wondering if there's a way to run IntelliJ's compiler from the command line, or if anyone has any insight into how I can get javac to work for just the one file in my whole project scope.
Any help is appreciate, thanks!
IntelliJ delegates (by default, there are options to delegate to the Eclipse compiler or other ones) to the javac compiler.
If you do not want to import your project into IntelliJ, then you can use maven from the command line to build the project.
If you do not want to build the whole project, then you can use javac from the command line.
To generate your classpath, use :
mvn dependency:build-classpath -Dmdep.outputFile=classpath.txt
classpath.txt will contain your classpath.
From then you can do : javac -cp (contents of classpath.txt) your java file.
IntelliJ is fast even on large maven projects and it can easily compile into an exploded war your tomcat would point to. It is unclear to me on why you would not want to benefit from IntelliJ.
Related
I am looking into the github project located at,
SymbolicRegressionInJava. I am familiar compiling java code into jar file but not one huge project using Maven. I looked into Maven and it is another complex system that need to be figured out. The bin folder has already a compiled jar file. I used a command
jar -tf symbolic_regression_1.0.jar
to see the list of classes used for the project. It has both gp and ga directories. I added ga (from another github) folder where is gp folder is at ../src/.. Instead of Maven (which I cannot figure it out even with a tutorials), I attempted manually by typing
jar cvf test1.jar *
It compiled, however, it failed to run like symbolic_regression_1.0.jar. What I am missing here?
Well, I has a doubt about compiling a java project into eclipse.
Note: My project is not using maven.
If i want to get a .ear or .jar or .war file
what is the way?
I want to compile my project and get all compilation errors, because I change my jdk version, from jdk 1.5 to jdk 1.8
And this is why I want to compile it getting my compilaion errors, to fix them and get the ear or war files
I mean, may I compile from
project -> clean -> built automatically
And this gonna give me this kind of files?
Or i have to compile it from command prompt?
Hope you can help me, any idea is a good one.
Thanks a lot.
Right click on your project > Export > Runnable JAR file or just JAR file.
From there you have many options concerning libraries: extract them, pack them, or just put them aside the generated jar.
I have a NetBeans project I would like to compile from the command line. There are many other questions on StackOverflow about how to do so, but they explain how to compile the project using commands like javac src/*.java.
I haven't changed my NetBeans project's build settings. By default, how can I compile my project from the command line using Ant? Once I've built my project, where is the compiled file located, and what format is it in (i.e., .class files, one .jar file, etc.)?
(I understand that asking how to use Ant to compile my project in general is too broad of a question. That's why I'm specifically asking about how to compile using NetBean's default configuration for a project.)
I'm using NetBeans 8.0.2.
ant compile Compiles the project (.class files are placed in the build/classes folder)
ant jar Compiles the project (see above) and builds a JAR ( located in dist/ )
If that doesn't work for you, check ant's output for errors. (Is the JAVA_HOME Variable set properly?)
I'm totally agnostic IDE developer. After several frustrating years trying to emerge "netbeans ant config" to something usable from command line I became to create a wrapper for netbeans ant.
https://github.com/albfan/ant-netbeans
By now you can:
detect defined targets with standard
$ ant tabtab
Rely on project will honor JDK_HOME
and most important
Expect all ant target to complete smoothly, passing test and whatever stuff implied.
I have a maven application under eclipse . The jsp pages and WEB-INF folder are located under the path NomeMiaApplicazione\src\main\webapp. I run these commands : mvn clean ,
mvn eclipse: eclipse and mvn compile under the root folder of the application, and in all three cases, the build is successful. However when I access the folder ( into the workspace )
. metadata.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\NomeMiaApplicazione
, there are no jsp pages . what would be the solution for this problem ? thks !
It is necessary to clarify the role of the commands you used and their impact on Eclipse.
The mvn eclipse:eclipse command creates the Eclipse project files, in order to save you the hassle of configuring a new project and identifying all the sources for it. This command is also equivalent to creating a new Eclipse project from an existing Maven project using the m2e Eclipse plugin. See also this page regarding the eclipse:eclipse command. That being said, you only need to run such command once, and then import the resulting project into Eclipse.
Secondarily, mvn compile builds your source files into the target directory of your NomeMiaApplicazione root folder. This command does not involve Eclipse in any way. Also, web resources are still not packaged. To package them, you need to issue mvn package: you will then find the <artifact>-<version>.war file again under target, and the pre-packaged content under target\<artifact>-<version>. Beware that, in order to account for the webapp content, your Maven packaging must be of type war. Check the pom.xml for the <packaging> tag.
Finally, deployment is still another issue. If you actually need to move your .war file from the target directory to somewhere else (namely, an autodeploy folder of a servlet container), you can configure the Maven Deploy Plugin and issue mvn deploy. I'd rather suggest you to search SO for deploy war eclipse and/or deploy war maven, since there's plenty of related stuff. In the first case, you will find how to use Eclipse as a facility for deployment, while the second case leverages the command line to provide a more portable/flexible deployment procedure.
That's because mvn compile ends on compile phase of Maven's default lifecycle. Do mvn package and check then. And by the way, default Maven output directory is target so rather check it instead of kind of WTP temporary dirs.
I have a Java project that utilizes Jython to interface with a Python module. With my configuration, the program runs fine, however, when I export the project to a JAR file, I get the following error:
Jar export finished with problems. See details for additional information.
Fat Jar Export: Could not find class-path entry for 'C:Projects/this_project/src/com/company/python/'
When browsing through the generated JAR file with an archive manager, the python module is in fact inside of the JAR, but when I check the manifest, only "." is in the classpath. I can overlook this issue by manually dropping the module into the JAR file after creation, but since the main point of this project is automation, I'd rather be able to configure Eclipse to generate properly configured JAR automatically. Any ideas?
*NOTE*I obviously cannot run the program successfully when I do this, but removing the Python source folder from the classpath in "Run Configurations..." makes the error go away.
Figured it out, had to add the source folder with the Python module in it as a class folder in the Build Path project properties. Not sure if this next part is necessary or not, but since the module is not compiled, I added the folder again as "Attached Source" after adding the class folder.
Have a look at the maven-jython-compile-plugin and its demo project at http://mavenjython.sourceforge.net/ . It allows bundling jython with dependencies into a standalone jar.