FAQ Database Discussion Community


Parse javac compilation errors [closed]

java,parsing,javac
I have done lots of looking around and can't seem to find an existing library for parsing javac compilation errors. I am considering implementing a "javac error parser" myself but I can foresee that it probably won't be straight forwards (lots of bits to consider). I am not using ant...

Ant javac task errs out: [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6

java,ant,axis,javac
I'm trying to run an ant task that uses axis2-ant-plugin-1.6.0.jar\org\apache\axis2\tool\ant\AntCodegenTask to perform a WSDL2Java operation. At the top of the ant script, I define java6.boot.classpath: <property name="java6.boot.classpath" value="${env.JAVA6_BOOT_CLASSES}"/> And I have the JAVA6_BOOT_CLASSES environment variable set to C:\dev\java\64-bit\jdk-1.6.0_45\bin. The pertinent ant target is as follows: <!-- dist.jar target --> <target...

java file compilation with file extension

java,javac
When we compile java program we use javac file.java command but while running we use java file. So why it is necessary to explicitly specify file extension while compiling and not needed when we run the java program?...

Could not find or load main class onjava

java,tomcat,javac
I have the following code and I am trying to create a connection to a database. I get an error "Could not find or load main class onjava" when I run the command: java -cp . onjava I am able to run the javac -classpath "C:\CATALINA_HOME\lib*" onjava.java command Both of...

Manually compile and run multiple packages using javac/java

java,javac
Let's say I have the following folder structure: \src\com\proj\pp1\stuff where com.proj.pp1 and com.proj.pp1.stuff are the two packages I have: -src -com -proj -pp1 tester.java -stuff some other .java's Being the main function in tester.java, and using the classes declared in /stuff. In tester.java I declare the imports that way: package...

Cannot find symbol : default access interfaces(declared in different src file) implemented on a public class java using `javac` command

java,interface,javac
This is a really novice question but I am not able to implement any default-access interface from the first source file('F:/Java_Practice/src/listpage1/interfaceTest/InterfaceCan.java;`) on the public class in the second source file(F:/Java_Practice/src/listpage1/interfaceTest/InterfaceCan1.java;). Please throw light on this. Thankyou! /* Source file name listpage1.interfaceTest.InterfaceCan1.java */ package listpage1.interfaceTest; import static java.lang.System.out; public interface InterfaceCan1...

How can i build to a folder that lives one directory down from my current folder

java,cmd,javac,filepath,shortcut
I want to compile to a file that lives in folder src. The build folder lives in the same folder as my src folder. So in CMD i am currently in C:\Programming Projects\Java Sample Projects\src> I want to build to C:\Programming Projects\Java Sample Projects\build> I know i can use the...

Ant apache NoClassDefFoundError

java,xml,ant,javac
I am having some problems when I build the file build.xml. I know it some problem with the class path of the tag javac, but i don't know how to solve it. [java] Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/core/Response [java] at java.lang.Class.getDeclaredMethods0(Native Method) [java] at java.lang.Class.privateGetDeclaredMethods(Class.java:2521) [java] at java.lang.Class.getMethod0(Class.java:2764) [java]...

SublimeLinter-javac not recognising other packages

java,sublimetext,javac,sublimelinter
I have a Spring Product That I'm trying the use sublimLinter-javac with, and there are a few packages scattered around the project. The problem is that sublimeLinter-javac is not recognising these packages or the classes within. So I end up with 200+ errors per file making the listing pointless. How...

Intellij long “integer value is too big” but in range of long.maxvalue

intellij-idea,javac,long-integer
This might be a silly thing but how is this possible that compiler will show this while Long.Max = 9223372036854775807 ?...

Why if I try to execute a class containing the main() method from within its package I obtain an error message?

java,java-ee,ant,jvm,javac
I have a Main class containing the main() method declared into a package named mainPkg. Now I use an ANT script to perform the compilation with Javac, this tartget: <target name="compile" depends="clean"> <mkdir dir="build/classes"/> <echo>INTO compile TASK</echo> <echo>BASE DIR: ${basedir}</echo> <echo>CLASSPATH: ${basedir}\lib\ojdbc6.jar</echo> <javac srcdir="src/mainPkg/" destdir="build/classes"> <classpath> <fileset refid="classpath.compile"/> </classpath>...

Error : Could not find or load main class Protection

java,javac
package package1; public class Protection { private int pri=1; protected int pro=2; public int pub=3; public void show() { System.out.println("Value of private variable is :"+pri); System.out.println("Value of protected variable is :"+pro); System.out.println("Value of public variable is :"+pub); } public static void main(String s[]) { Protection p=new Protection(); p.show(); //p.pro=0; }...

How does javac automatically compile dependencies of a class

java,import,package,javac
Given the following directory structure: /top |--- wrk |--- pkg |--- A.java |--- B.java Assume that the two files A.java and B.java contain the following code, respectively: // Filename: A.java package pkg; class A { B b; } // Filename: B.java package pkg; class B {...} Assuming that the current...

Running multiple Java classes

java,compilation,classpath,javac
I am trying to run a code with multiple Java class files and a jar file which is from a library I downloaded. I compiled them with the following: javac -cp "quickfixj-all-.jar" BTCCMarketDataRequest.java Bot.java The Bot class has the main method and the BTCCMarketDataRequest file has a bunch of other...

Reference to the final field from lambda expression

java,java-8,javac
Recently I've found a subtle difference between anonymous class and lambda expression: public class FinalTest { final Runnable x = new Runnable() { @Override public void run() { System.out.println(x.hashCode()); } }; final Runnable y = () -> System.out.println(y.hashCode()); } Usually lambdas are equivalent to the anonymous classes. Even my Eclipse...

Classpath invalid flag - Java

java,compiler-errors,javac
I am using javac to compile a file called Rengine.jar. I tried: javac –classpath ./REngine.jar javac –cp ./REngine.jar javac ./REngine.jar javac –classpath REngine.jar And here are the errors that I got: javac: invalid flag: –classpath Usage: javac <options> <source files> use -help for a list of possible options javac: invalid...

Do repeating annotations need a public container?

java,eclipse,java-8,javac,repeating-annotations
I noticed a discrepancy between Eclipse's compiler and javac while using repeating annotations. The repeating annotation and its container were in the same package, but the former was declared public, while the latter remained package-private. Eclipse had no problem with the arrangement, even though the repeating annotation was referenced in...

Troubleshoot slow compilation

java,performance,compilation,javac
What should I do to investigate and troubleshoot a slow compilation problem? My project has about 100 classes and takes more than 45 seconds to compile, which seems very slow to me. As a reference, I have another project with 50 classes that compiles in 3 seconds. ps: I use...

Why doesn't the compiler spot certain causes of ConcurrentModificationException

java,iterator,javac
It's very clear that this code is modifying a list during iteration. public class ArrayIterator { public static void main(String[] args) { List<String> list = new LinkedList<>(Arrays.asList("A","B","C","D","E")); Iterator<String> it = list.iterator(); while (it.hasNext()) { list.remove(it.next()); } } } And so we get the expected Exception Exception in thread "main" java.util.ConcurrentModificationException...

Bash compiling Java classes and JARs

java,bash,unix,classpath,javac
I am attempting to write a script that will automate a few tasks that I do regularly. The folder structure of my files is like so: ./ sampleScript.sh src/SampleProgram.java In addition to this, my Java program relies on the ojdbc6.jar file, which resides in ~/sampleFolder/lib. I have attempted to compile...

Running a java program through command line

java,jar,javac
I am running a Java program with the following command: java -cp .:./* com.bot.fix.botclient All the jar files are in the same directory. It works FINE! But what if I want to run it from a different folder? The full location of the java program is: FIX/fixprog/src/com/fix/botclient But if I...

Why does the Java Compiler copy finally Blocks

java,jvm,javac,try-catch-finally,try-finally
When trying to compile the following code with a simple try/finally block, it produces the output below (viewed in the ASM Bytecode Viewer): Code: try { System.out.println("Attempting to divide by zero..."); System.out.println(1 / 0); } finally { System.out.println("Finally..."); } Bytecode: TRYCATCHBLOCK L0 L1 L1 L0 LINENUMBER 10 L0 GETSTATIC java/lang/System.out...

Run Java program on Windows Command Line 1000 times

java,windows,loops,cmd,javac
So I have a java program... it takes two arguments and I need to run it 1000 times. The first argument doesn't change, but the second one needs go to from 1 to 1000. How do I do this? I've been trying to figure this out for a long while...

Local variable might already have been assigned

java,javac
I know there are a couple of questions on stackoverflow dealing with the problem of already initialized variables but I could not find anything answering my question with regards of local variables. Consider the following excerpt: public class Test { public static void main() { final int i; try {...

If I compile java with javac do I need JVM?

java,jvm,javac
I recently learned about how Java uses the JVM to make itself platform independent and I often write code and compile it with the javac command in terminal (Mac OS X). So my question is whether javac compiles it for JVM or if it is compiled directly to machine code?...

Ant - skip task, when directory does not exist

ant,javac
I have set of projects, that use build file from "parent" project. All works fine until each project contains test directory. Now I have a new project, that have no tests yet, so I would like to do not run tests task if the test directory does not exist. (Original...

Why calling method with generic return on a generic class is considered unsafe by javac?

java,generics,javac,raw-types
Consider the following code: public class Main { public static class NormalClass { public Class<Integer> method() { return Integer.class; } } public static class GenericClass<T> { public Class<Integer> method() { return Integer.class; } } public static void main(String... args) { NormalClass safeInstance = new NormalClass(); Class<Integer> safeValue = safeInstance.method(); GenericClass...

Compiling multiple jar and java files using javac

java,jar,javac
I downloaded a sample code written in java that has multiple jar files and java files. I am not a Java programmer so I am having a hard time compiling the code. Here's my attempt: javac -classpath lib/*.jar src/*.java However this is what I get: javac: invalid flag: lib/dom4j-1.6.1.jar Usage:...

Need to compile Java program with TWO packages and MANY classes from command line but can't get syntax right

java,netbeans,javac
I have only used Netbeans to compile to this point. Now I have a complex project and though I have gotten compilation with errors, I don't know how to include the gbl package (lack of which led to many errors). Here's what I tried, among quite a few others: C:\Users\Dov\Google...

Unchecked warnings are not removed with Javac @SuppressWarnings annotation

java,compilation,warnings,javac,compiler-warnings
I cannot remove my warnings with unchecked cast. I believe this is very strange because I have added the @SuppressWarnings("unchecked") annotation on the method but the Javac still showing the warnings. [unchecked] unchecked cast (List<Integer>) getObject(LIST); return (List<Integer>) getObject(LIST); required: List<Integer> found: Object I have create an Example, It throws...

How hadoop command works with javac

java,linux,shell,hadoop,javac
I was reading Apache mapreduce tutorial I was able to run the example and get the desired result. However, I am not able to understand how it is asked that we should run following to compile the Java file. $ bin/hadoop com.sun.tools.javac.Main WordCount.java I went through the hapdoop command details....

Using external class files in a package

java,package,classpath,javac
I have a program that uses an external library called JHelper located in a neighboring folder home |--lib | |--JHelper.java | `--JHelper.class `--prj `--HelloWorld.java The HelloWorld.java file //package prj public class HelloWorld { public static void main(String[] args) { String echoed = JHelper.echo("Hello World"); System.out.println(echoed); } } I can compile...

What to do about “unchecked call to generic class?”

java,generics,javac
I have this class: package Main; public abstract class Click123<T extends java.awt.Component> //////////////// { boolean debugging = false; public abstract void singleClick(java.awt.event.MouseEvent e); //////////////// public abstract void doubleClick(java.awt.event.MouseEvent e); //////////////// public abstract void tripleClick(java.awt.event.MouseEvent e); //////////////// public abstract void manyClick(java.awt.event.MouseEvent e); //////////////// public abstract int getFreq();// how long thread sleeps;...

Annotation information missed after compiled with ECJ Compiler

eclipse,javac,ecj
I found the bytecode compiled from ECJ compiler has the annotation information missing. The source code decompiled from bytecode compiled by javac: public class HelloWorldApp { @GetAction("/hello") public String sayHello() { return "Hello World!"; } } The source code decompiled from bytecode compiled by ECJ: public class HelloWorldApp { public...

Compile a java file using docker with own path

java,ubuntu,docker,javac
Hy. I'm trying to compile a .java file using docker. I read the files on docker's website, also I read these links: docker's website about volumes and another question I had put up for gcc compiler I understood the concept for the gcc compiler since it doesn't create any extra...

Maven compiler plugin error: can't access enum (bad signature, bad class)

java,maven,enums,javac
I am using maven-compiler-plugin:2.3.2 and every time I make changes in classes which have an enum (ContentType) in imports, I need to make clean, otherwise it gives me: ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project wp2: Compilation failure [ERROR] /home/semyon/development/.../ContentManager.java:[15,46] error: cannot access ContentType [ERROR] -> [Help 1]...

How does javac process Unicode glyphs?

java,unicode,javac
I tried System.out.println("ñ"); and it prints ñ. Why didn't javac run through an error?