Headless Java command line build always completes - java

Is there a way to stop a headless eclipse build for java using the apt compiler if an error has occurred?
A bit of background:
I am trying to build my java project from the command line using
C:\eclipse\eclipsec -nosplash -application org.eclipse.jdt.apt.core.aptBuild -data "../.." -build JavaMain
However, I have recently noticed this compiles my binary even when there are errors in the project such as missing files or missing variables.
I have tried adding -Declipse.exitOnError or removing the -nosplash but it still continues on like a runaway freight train. I have looked for documentation on eclipse apt but all I can find is two pages in their help index which shows me the exact same command I am already using. I checked some other stack overflow questions such as
Build Eclipse Java Project from Command Line
which recommend the same command.
I know that eclipse builds can be done using ant but I was kind of hoping to keep it my project simple with a single command. I know I have to be missing something, there has to be a way for a compiler to report errors.
Also please do not hesitate to correct me on anything I have forgotten to add to this question, this is my first stack overflow post so I am bound to have missed something.

Related

IntelliJ - How to run current program regardless of errors in unrelative files

I am start learning Scala, I am using
Java 7 and
IntelliJ IDEA 2016.1.4
Build #IC-145.2070, built on August 2, 2016
JRE: 1.8.0_77-b03 x86 JVM: Java HotSpot(TM) Server VM by Oracle Corporation
I got some sample code programs online and trying to run one by one.
But not working, while I try to run, it showing errors in other files but there is no relationship with them, all most all are independent Scala classes only.
IntelliJ Idea, run code regardless of errors in unrelated project files
I followed this similar issue, but I am not able to find options they suggested. like "Make before launch" and other might be very old post.
The option is still there, you just need to look for it in your run configuration window.
As you can see in the below GIF, when you create a run configuration it will implicitly run make before running, and initially it will fail.
The, you edit the run configuration and replace make with make, no error check. If you get a ClassNotFoundException when launching it right after, just re-run it again. I haven't figured out why this happens, it's probably related to how IJ cleans and compiles the classes in this particular case.

Java executable doesn't start

I'm having a frustrating issue with a java program I have been working on. I have not had this issue often in the past and I have actually created many versions using this same code and had no problems.
Suddenly, executable JARs of this program will not start. I have tried running them through the command prompt with Java and I get message about the main class not being found.
I have done a search here and none of the answers work for me. I have tried the following:
Removing the system library in the build path settings and adding it back. (The system library is [jre1.8.0_66]).
Changing the compliance settings from 1.7 to 1.6. I don't have an option for 1.8 and the JDK check box that says "Use compliance from execution environment on Java Build Path" is disabled.
Removing the main class and adding it back.
Using the package and export options for libraries.
I'm really not sure what else to do. I've tried doing a rebuild on the project many times and also tried restarting eclipse and re-exporting. I'm certain that I am selecting the main class when in the export preferences.
Any help or suggestions would be greatly appreciated as this has become very frustrating.
From the comments, it seems to me that you are not executing your JAR correctly. As stated in the comments, you are executing your JAR with java {jarname}. This syntax would only work with running a compiled Java class with a main method. To run a JAR, use:
java -jar {jarname}

Ignore vim java warnings

I am using the janus distro of vim and started to editing some java files..
I have some errors on the left, saying that it can't locate my packages..
Where are those errors are coming from? and how do I ignore those errors?
I took a look (not so deeply) the Janus project, it used syntastic as syntax checker.
Java checker of Syntastic has a command :SyntasticJavacEditClasspath, which allows you to add your classpaths. Also it supports load cp from maven repositories. just take a look the https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/java/javac.vim
hope it helps.

Command line Ant not recognised

** Edit ** I have summarized the solutions I found to this problem in this post.
I am installing Android into Eclipse which I have been using for Java for 2 years. As part of this I have installed Ant and also upgraded to JDK1.7.0
Per the Cordova get started guide, I now run command line tests by typing java to see if it is recognized, then ant.
java is recognized (thanks to Nikolay Ivanov's help in a previous question)
ant fails to recognise anything
I have ANT_HOME set to "c:\Developer\apache-ant-1.8.4"
My PATH variable includes "%ANT_HOME%\lib".
I have also tried %ANT_HOME%\bin and %ANT_HOME%.
The ant.jar file is in c:\Developer\apache-ant-1.8.4\lib
But "ant" on the command line is still un-recognised.
FWIW, I now restart my command line interface every time I make a change in my environmental variables...
** Edit, I have removed %ANT_HOME%\bin from my build path and replaced it with "C:\Developer\apache-ant-1.8.4\bin".
I now have a new error "Buildfile: build.xml does not exist! Build failed"
Path should include %ANT_HOME%\bin but not %ANT_HOME%\lib.

Thinking in java library installation

Hi i've been trying to install the library on Thinking in Java book 4th edition and i hit a very thick brick wall. I've done everything that the guide from the website told me to do and i still can't get the library to work. From what i've read it seems that the problem is from the build.xml files. having no xml knowledge I am clueless about how I have to modify it in order for it to work. In both cmd and eclipse I am getting these error
c:\TIJ4\code\build.xml
Build Failed
c:\TIJ4\code\build.xml:59:J2SE5 required
Can anyone tell me what I should do ?
I am using eclipse if there is a simpler solution by using eclipse rather than ant please help me out. It's been a week now and I still can't make it work.
The important thing to do is to realize that your ant file has a specific java requirement.
Something to try that might fix this very easily : I believe you can remove any references to a specific JDK, and if you have a reasonably up to date JDK, the build will succeed.
The definete fix : Look into the exact (line 59) of your build file, and try to satisfy the java version that line requires. Java is generally backwords compatible -- something designed to run in J2SE5 should run in the latest JDK. Its not terribly difficult to update your JDK (just google for instructions on your OS).
The most common mistake I see is that people who have the java run time installed believe they also have the Java SDK as well.
Does this "install the library" means you want to look at the code and run them in your eclipse? If so I can share my experience with you.
First run the Eclipse.py script; this will add package info to the source code
Create a new Java project in Eclipse, and then just copy all the source code folders to the src source folder in eclipse, these folders will then be recognized as Java packages.
You should be able to run the classes with a main function.
You can also configure which java version to use for this project in Eclipse build path. 1.5 or higher will work.

Categories