![](/img/trans.png)
[英]Unable to Pass input to multiple methods in a Java program using command line arguments
我使用以下命令將輸入傳遞給 java 程序: 通過使用此方法,輸入僅由第一種方法(主要)接收代碼:import java.util.Scanner; import java.util.Arrays; class Main { public static int read() { ...
[英]Unable to Pass input to multiple methods in a Java program using command line arguments
我使用以下命令將輸入傳遞給 java 程序: 通過使用此方法,輸入僅由第一種方法(主要)接收代碼:import java.util.Scanner; import java.util.Arrays; class Main { public static int read() { ...
[英]when invoking a java method by method.invoke() its not returning any value instead print in the console log
你好,請幫我找到解決這個問題的方法,我正在為 java 程序創建一個 web 編譯器 我已經實現了 java 內置編譯器 class 來編譯代碼,它也給出了 output 但它給出了 8834378106334 output 返回 object 或一些字符串變量,因此我可以在前面顯示 output。 ...
[英]Get Resource in openjdk 11
我如何獲得在 JDK 8 上運行的 JDK 11 的資源? 我試過 getClass()、ClassLoader,但我得到的是 null。 錯誤圖片 ...
[英]System Java Compiler behaves different depending on dependencies defined in maven
最近我觀察到(至少對我而言)Java 編譯器“ToolProvider.getSystemJavaCompiler()”的奇怪行為。 如果我嘗試在“裸”maven 項目中編譯不可編譯的 java 文件,我可以獲得預期的錯誤。 如果我添加某些依賴項(我在添加 log4j 時首先觀察到這一點) ...
[英]Compiling and running java project with many dependencies classes in other directories
我的所有目錄都有這樣的結構: 我正在嘗試編譯和執行 ServerMain 和 ClientMain。 以下編譯有效: 我必須不在 src 中執行程序,而是在以前的目錄中執行程序,因為在代碼中有一個 function 從 cfg 目錄中的配置文件中讀取。 我嘗試執行此命令,但出現很多錯誤:Class ...
[英]Does a Java compiler optimize ad hoc instances of `Set.of`, `List.of`, and `Map.of` in loops as constants
給定以下代碼片段,其中創建了一個Set的臨時實例,今天的 Java 編譯器會看到他們不需要為每個循環傳遞創建實例並將set優化為一種最終常量,這樣實例就是整個循環都一樣嗎? 這個問題同樣適用於while和do while循環。for (/* a loop that iterates quite of ...
[英]Can a Scala compiler plugin transform the autogenerated accessor methods of scala case classes?
經過Scalac進程的解析器階段,如下案例classcase class ExampleCaseClass(var s:String, var i:Int) extends ContextuallyMutable 采用中間形式:Clazz(case class ExampleCaseClass ...
[英]Compiling Java file with Jar dependencies using command prompt in windows
我有一個帶有 jar 依賴項的 java 文件,我想在 Windows PC 的命令提示符下使用命令編譯它們。 我已將所有 3 個 jar 文件和 java 文件放在 D 盤的同一文件夾中。 我需要在環境變量中設置類路徑嗎? 我的 jar 文件名是 juh-4.1.2.jar、ridl-4.1.3. ...
[英]Facing NoClassDefFoundError despite jar being in classpath (dynamic compilation)
在 tomcat 服務器中,在運行時,我正在讀取 java 類文件並使用內部使用JavaCompiler的InMemoryJavaCompiler庫動態編譯它們。 代碼示例 - 這里 sb (Stringbuilder) 表示從 WEB-INF/lib 目錄中讀取的 jar,以冒號分隔。 該 ...
[英]How to validate Java code programatically?
給定源代碼和 Java 版本,我需要能夠驗證代碼是否可以編譯。 如果代碼無法編譯,我需要能夠返回源代碼中的錯誤。 以下解決方案有效,但僅適用於您機器上當前使用的 Java 版本。 無論如何我可以實現以下功能嗎? ...
[英]Getting java.lang.ClassNotFoundException when using package
我有一個 java 文件ComPac.java ,代碼如下: 該文件位於路徑: /home/ec2-user/java_c 為了編譯這個文件,我運行了javac Compac.java ,並生成了 class 文件。 現在輪到運行 class 文件了。 所以我做了java ComPac (截圖如 ...
[英]Why is Java command working with java files as parameter
我有 java 文件HelloWorld.java ,代碼如下: 現在我的理解是,要編譯和運行它,我們需要兩個步驟:步驟 1) javac HelloWorld.java步驟 2) java HelloWorld 。 很明顯,命令 java 將 class 文件名作為其輸入參數。 However ...
[英]Java creating a generic class that implement another generic interface with constraints
要實現的接口: 具體實施: 意外的界限這種模式在 Java 中是否可行? ...
[英]Compile and run Jade agents using JavaCompiler and URLClassLoader
我找不到通過手動調用 JavaCompiler 來執行我的代理 JADE class 的方法。 我正在嘗試實現一個模擬器,我添加了一個導入功能,允許人們加載他們的 JADE 代理類,我會在模擬器上執行它們以提取數據。 這是導入代碼: 這是正在編譯的主要內容: 我嘗試同時包含 JADE.rar 的路徑 ...
[英]I'm having trouble in running the code compiled using javax.tools.JavaCompiler
我正在開發我的第一個 java 項目,即一個 TextEditor,它也可以編譯和運行文件。編譯器(javax.tools.JavaCompiler)工作正常,但是當我嘗試運行“.class”文件時,什么也沒有出現。 我需要幫助。 以下是編譯代碼: 運行 .class 文件的代碼: ...
[英]How do I compile and run .java file with .class file in resource dynamically?
I'm trying to make my Main class print out in its console (eclipse) the output from Example1 class (in resources/ as.java file) that depends on Exam ...
[英]Error warning: [deprecation] signatures in PackageInfo has been deprecated for(Signature signature:info.signatures)
我在編譯時收到這些錯誤。 這是日志, 有人可以解釋一下這是什么意思嗎? ...
[英]Gradle custom JavaCompile task for annotation processing
我正在開發一個注冊JavaCompile任務的 gradle 插件,該任務應該觸發注釋處理過程。 這是我目前擁有的 在一個 android 項目中,當我應用我的插件並使用 gradle 運行任務時,到目前為止什么也沒發生。 我什至試圖在處理器的第一行拋出異常,但仍然沒有成功。 我是否遺漏了什 ...
[英]AbstractMethodError when calling overridden method of abstract class from a class compiled at runtime
讓我首先總結一下我到底想要做什么。 基本上,我使用 JavaCompiler package 在運行時編譯 class 以擴展我的超類“播放器”。 我唯一知道的是子類是它將擴展 Player 並覆蓋抽象方法 calcMove()。 為了在編譯后在運行時加載 class,我創建了一個 URIclas ...
[英]Strange behaviour of Kotlin compiler or Java decompiler
這個問題是由我的好奇心驅使的,所以我希望得到一個完整的答案,而不是簡單的“是”或“否”。 讓我們考慮這段代碼: 當我在 AndroidStudio 中使用“顯示 Kotlin 字節碼”工具,然后單擊“反編譯”按鈕時,我看到了這個 java 代碼(我刪除了一些不相關的東西):public final ...