Questions tagged [javac]

javac is the primary Java compiler, included in the Java Development Kit (JDK) from Sun Microsystems (now Oracle), and also in versions from other vendors.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Cannot run ajc compiled class file in the terminal using Java

I trying to learn aspectj for a project. I wish to run the java files from the terminal using ajc and java but I am unable to do so. I have 2 files in my directory HelloWorld.java and HWTracer.aj Here ...
  • 1
18 votes
1 answer
549 views

How to avoid javac warning: unknown enum constant, reason: class file not found, when dependency has optional annotations with enums

I have this example setup: p.E package p; public enum E { E } p.A package p; import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) public @interface A { p.E e(); } q.Test package ...
  • 207k
0 votes
1 answer
19 views

UnsupportedClassVersionError in Hadoop despite the version being correct

When I am running a JAR file using Hadoop, I am running into this error: Exception in thread "main" java.lang.UnsupportedClassVersionError: WordCount has been compiled by a more recent ...
  • 1
1 vote
1 answer
48 views

How to set the display language of javac 20?

Having a computer with the system property user.language set to de, I would like to see the compiler messages in English. In this post two methods are proposed for java8: to use the -Duser.language=...
  • 214
0 votes
2 answers
32 views

How can I verify all class files and Jar files used in my app are compiled for Java 8?

I'm using Java 11 and targeting Java8 but finding some libraries I'm depending on are not being compiled for running in Java 8. Is there a command that can look at an uber jar, and report all of the ...
  • 7,797
-1 votes
0 answers
46 views

how to configure environment variables for java 8 in windows 11

I installed Java 8 on windows 11 and tried to compile a java file in the terminal using the command "javac FileName.java"but the error crashes " javac : Имя "javac" не ...
-1 votes
0 answers
22 views

Starting Main.kt from cli with args intelliJ

I am new to Kotlin, working on a JetBrain project and for testing I should start the app by cli with two parameters. But I haven't found any information about how to do that. I have tried it with '...
0 votes
1 answer
65 views

Unable to compile java file containing apache camel program

I am a beginner at using Apache Camel. I have a maven project with the following structure: File Write_Paper contains the content below: When I compile this file by using cmd with: javac Write_Paper....
0 votes
0 answers
43 views

Easier way to run a main() method of a class not in Main.java

I'm working on the exercises in "Think Java" Chapter 15 "Conway's Game of Life". I'm a little confused by the way the provided code is set up. The program runs by typing "java ...
1 vote
0 answers
22 views

How to get the dependency information about public static final fields

Though jdeps can be used to get the class level dependencies, considering follow case: A.java: public class A { public static final int AA = 1; } B.java public class B { public static void ...
0 votes
0 answers
129 views

Gradle Annotation Processor dependency

General idea: I want to build a simple annotation processor on Gradle and Java 17 (Gradle 7.5, Java 17.0.6). And use it in another project with the same setup. here is my code: annotation-processor ...
0 votes
2 answers
86 views

How do you get a type use annotation on a class?

Consider: @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE_USE }) @interface A {} @A final class B {} This compiles. How, either using java.lang.reflect.* constructs or javax....
  • 14.8k
0 votes
1 answer
45 views

Java - cannot find symbol. Both Files in same directory

I am new to java and have been trying to learn it and now I have been facing this error even though both the files are in the same folder : BankTest.java:3: error: cannot find symbol ...
  • 55
1 vote
1 answer
48 views

Where in the javax.lang.model.* hierarchy is this type use annotation recorded?

Suppose I have: @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE_USE }) // no PARAMETER, note public @interface A {} public final class B { // @A annotates the use of the type ...
  • 14.8k
1 vote
0 answers
22 views

Eclipse compiler and OpenJDK javac behave differently when assigning generic types with wildcards

The following code compiles and runs just fine with Eclipse 2022-12 (4.26.0). public static void main(String[] args) { List<List<?>> list = Arrays.asList(Arrays.asList("test")...
  • 1,339
1 vote
2 answers
2k views

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" within flutter

the problem with android licenses and when i tried fixing it the problem was in java when I typed flutter doctor [√] Flutter (Channel stable, 3.7.1, on Microsoft Windows [Version 10.0.22621.1105], ...
0 votes
0 answers
20 views

Converting ANT build for Java 8 non-modular project to Java 11 modular project with non-modular dependencies

Trying to convert a Java 8 project to use modules in Java 11. We created the module.info file in Eclipse and everything is compiling fine within Eclipse. But we’re having problems setting up the ...
  • 1
0 votes
1 answer
14 views

Ant cannot compile with cross-release process

I have a ant process to compile a java 1.8 application. Ant is lauched from Eclipse IDE in Windows running with java 1.17. If I try to run Ant process using a separate JDK (1.8), different from the ...
  • 9,319
0 votes
1 answer
26 views

Unobvious failure of Gradle's Jaxb generation with Ant configuration inside on executing javac command

We have a part of Gradle config in order to generate Java classes from WSDL. task genJaxb { ext.sourcesDir = "${buildDir}/generated-sources/jaxb" ext.classesDir = "${buildDir}/...
  • 3,783
0 votes
0 answers
10 views

variable not getting updated as expected in Java

I am learning Java and have encountered an unexpected problem: variable i is getting updated in mouse listener but updated value is not getting passed back to main program. But if I uncomment Thread....
  • 1
0 votes
1 answer
171 views

Get java class version from javac or JRE without a compiled class

Java class version can be obtained from a class binary using javap javap -verbose Test | grep 'minor\|major' minor version: 0 major version: 55 Is it possible to know in advance which class ...
  • 9,894
1 vote
0 answers
44 views

java Annotation Processor only scans the .java files specified by the javac compiler

I wrote an annotation processor (to copy some java sources in my compiling directory). I was surprised to see that only the files specified on the javac command line are processed by my annotation ...
  • 34k
1 vote
0 answers
44 views

How does javac determine the source dependencies of the current source file?

Consider the following two classes, defined in two source files: Foo.java public class Foo { } Bar.java public class Bar { Foo foo; } When we invoke javac Bar.java, the current directory now ...
  • 70.5k
0 votes
1 answer
20 views

Ant/Javac not running annotation processors

I seem to be getting an odd compile error while building my main project. I have annotations in the source that is supposed to be generating class files, like NbBundle.Messages, and they are not being ...
1 vote
3 answers
63 views

Why does the Java Compiler not inline these calls in a single if clause?

I have been pulled into a performance investigation of a code that is similar to the below: private void someMethod(String id) { boolean isHidden = someList.contains(id); boolean isDisabled = ...
  • 45
0 votes
1 answer
75 views

React Native CLI

Task :app:compileDebugJavaWithJavac Task :app:compileDebugJavaWithJavac FAILED w: Detected multiple Kotlin daemon sessions at build\kotlin\sessions Deprecated Gradle features were used in this build,...
4 votes
3 answers
124 views

Inner class access field before java-11

Having a class like this: public class Sample1 { public class Inner { private int f; } void go() { Inner in = new Inner(); int value = in.f; } } The byte-...
  • 115k
0 votes
0 answers
33 views

Is it possible to get a diagnostic's arguments using the JavaCompiler Interface?

I'm using the JavaCompiler Interface to compile source code files from within a Java program. I've successfully written code that captures the errors that exist in the source code file. I'm now trying ...
1 vote
0 answers
10 views

Are there any disadvantages in setting a lower java compliance level than the available java sdk?

When updating a large java project from one LTS version (java 1.x) to the next (java 17), one may set the java compliance level of the compiler of the new javac compiler to match older versions of the ...
  • 166
1 vote
0 answers
74 views

Javac will not run despite Java being installed

While I have some experience in Python and JavaScript, I am new to Java and am trying it out for the first time. To get started, I went to http://www.java.com, downloaded the dmg there, and then used ...
  • 136
0 votes
1 answer
42 views

How does masking work with int/Integer in java?

Since bytes are signed in java, in order to obtain unsigned integer values we mask with 0xFF asper: byte signed = -1;// -—> 0b11111111 int unsigned = signed & 0xFF;// —-> 0b11111111 & ...
  • 761
-2 votes
1 answer
215 views

Class file has wrong version 55.0, should be 52.0

I am trying to run some code and am receiving the following error: > Task :compileJava FAILED /Users/sahil/Downloads/ptltrader-1.6.0/src/main/java/com/pairtradinglab/ptltrader/model/validator/...
-1 votes
1 answer
154 views

How to downgrade JDK/javac - MacOS

I am trying to downgrade the jdk for a project I'm running from 17.0.5 to 1.8, but have not been able to replicate any of the results I've found online. Specs and attempts below. Specs: MacOS Big Sur ...
0 votes
1 answer
45 views

Does javac generate inaccurate line numbers compared to ecj (for this particular case)?

I use the following class which has this specificity in the equals() method that the return keyword and its expressions are split into several lines (return keyword is on its own line). package jd....
  • 619
0 votes
0 answers
19 views

How to get java files of all folder into source folder [duplicate]

I'm trying to create my workspace without IDE and I want to put files and packages in the source folder but I don't know how to compile all java files. I searched and found it, but this command only ...
2 votes
1 answer
50 views

Usage of an unlabeled break statement causes compilation to fail

There are tons of answers on StackOverflow related to the of usage break statement in Java, yet unfortunately, I was not able to discover a clear explanation to my Java beginner type of a question. // ...
  • 1,285
0 votes
2 answers
48 views

Why use source option in javac [closed]

I understand what source option does, but I don't understand why would someone want to use that. According to Oracle Docs: -source: Specifies the version of source code accepted. Source option ...
0 votes
1 answer
40 views

javac reports "package does not exist" even though classpath is set

I have a file Test.java (stripped down for debugging): import com.github.tkutche1.jgrade.Grade; I try compiling it with this command line and get an error: # javac -cp lib/com/github/tkutche1/jgrade/...
1 vote
0 answers
58 views

How do you use a class that was generated by an annotation processor? It says package does not exist

I have the world's simplest annotation processor: @SupportedAnnotationTypes("deoplice.processor.MyAnnotation") public class MySimpleProcessor extends AbstractProcessor { @Override ...
0 votes
0 answers
20 views

SPRING class file has wrong version 60.0, should be 55.0 [duplicate]

so i get this error /Users/apple/Downloads/Seasalt-Konsumen/src/main/java/com/seasalt/repository/KonsumenRepository.java:4:47 java: cannot access org.springframework.data.jpa.repository.JpaRepository ...
0 votes
1 answer
361 views

Patch jdk.unsupported module in Java 17

For various reasons, I need to continue to use some sun.misc classes in Java 17, specifically the BASE64Decoder class. (The algorithm used by the class has some specific behavior that other base 64 ...
0 votes
1 answer
95 views

How to generate Native header files from java files in Android Studio

I am trying to learn Android Native programming , but i cannot use the Javac -h to generate header files from java source files . javac -h "destination path desired for header files" then i ...
2 votes
1 answer
363 views

Gradle error when build, failed to calculate

I debug my app and found this error: 1. Caused by: org.gradle.api.internal.provider.AbstractProperty$PropertyQueryException: Failed to calculate the value of task ':app:compileDebugJavaWithJavac' ...
-1 votes
1 answer
82 views

'package does not exist' using javac to convert .java class with google play services imports

I have a .java class which uses imports from google play services. I want to put this class in a .jar to package with my project, but using javac filename.java in the terminal gives me a bunch of ...
0 votes
0 answers
14 views

Possible values for Ant Javac attributes "source", "target", "compiler" across various JDK versions?

For the Ant javac task below, is there a resource that lists the values of source, target, and compiler for various JDK versions? <target name="_compile" depends=""> <...
0 votes
0 answers
32 views

How to configure JavacProcessingEnvironment to print log messages in multi-line mode?

I have an annotation processor from which I want sometimes to log errors. These errors are logged as such: processingEnv.getMessager().printMessage(kind, msg, element) ... where processingEnv is an ...
  • 11.8k
0 votes
0 answers
17 views

How to fix Task :app:compileDebugJavaWithJavac FAILED in React Native? [duplicate]

I am trying to build this react native application and when I run npx react-native run-android, I get the following error, please help I tried cd android && ./gradlew clean and that shows ...
0 votes
1 answer
49 views

javac is not working. error: file not found: Sum.java always pops up when i want to compile the program. Can anyone help me with this?

Here you see the problem Im the new to programming.
-4 votes
1 answer
53 views

Return type mismatch and Java compiles

I am curious as to how the below code compiles @Bean(name = "ErrorDecoder") public ErrorDecoder streamHubErrorDecoder() { return FeignException::errorStatus; } The type of ErrorDecoder ...
1 vote
1 answer
1k views

Will be using a wiremock-jre-8 dependency within a java 11 project an issue?

Disclamer Sorry in advance if this is a stupid question, but my research to clarify this was not as successful as i needed it to be. Problem description I am working on a project using jdk 11 and in ...
  • 13

1
2 3 4 5
49