Questions tagged [java]
Java is a programming language. Use this tag for all questions on how to use emacs to work with Java code.
60 questions
0
votes
2
answers
191
views
Emacs 30 and Java tree sitter, how?
When I run M-x java-ts-mode it complains
Tree-sitter for Java isn't available
With C-h f java-ts-mode I see that the mode is built-in, but in the *Warnings* buffer I also see
No such file or ...
0
votes
0
answers
43
views
lsp-java-spring-initializr does nothing
I tried to follow the tutorial on this link and when I arrived to the Working with Java Project section, I found I cannot initialize a project. Everything shows up as expected until It asks for a ...
0
votes
1
answer
416
views
Multi-module Java project with lsp-mode/jdtls fails to build and run unit tests
I'm trying to marry emacs, lsp-mode, lsp-java, dap-mode and a multi-module Maven project's tests. The main goal is to be able to run and debug them; building the project would also be nice but mvn ...
0
votes
1
answer
137
views
dap-mode java debug configuration for JUnit test
I have a gradle multiproject with different java subprojects. I'm also using lombok in my code. When I try debug a JUnit test using dap-java-debug-test-method, I therefore get error messages regarding ...
0
votes
1
answer
94
views
How to change java file behaviour to use 2 character indentation
If I create a C file I get 2 character indentation which is what I want. However, if I create a java file, eg Hello.java then I am getting 4 character indentation. And I can't work out why.
My ....
1
vote
0
answers
147
views
How can I configure my emacs so I can program in java?
I installed Emacs recently, because I already had a good experience with Vim (another ide that gives the user freedom to modify the ide as the user wants) and as I am studying Java together with Elisp ...
1
vote
1
answer
2k
views
Emacs as Java IDE - How to run code?
I am looking at setting up Emacs for Java development.
As much as possible, I would like to achieve Emacs being comparable to IntelliJ IDEA in terms of features, and also ease-of-use / "things ...
0
votes
1
answer
851
views
lsp-java and its relation to the eclipse.jdt.ls language server
When using lsp-java with a 3 file project and one external jar, I am not using gradle or maven. I put the jar into a lib directory, open a Java file and everything works. Then I follow find-...
0
votes
1
answer
206
views
How to add an external library to java lsp
I am working on a simple java program, it uses a jason.jar and junit.*.jar (for testing). I usually run the tests through the command line; i never run my programs through and Editor/IDE, I always use ...
0
votes
1
answer
441
views
View documentation of Java inside of emacs
I want to view Java documentation like https://docs.oracle.com/en/java/ inside emacs.
I have tried lsp-java with lsp-ui but my setup wasn't enough.
0
votes
1
answer
159
views
org-mode: How to define then call a Java method using source blocks
I have a super simple example where I have a list, a Java method and a call to this method. It looks like this:
#+name: animals
- dog
- cat
- guinea pig
- horse
#+name: does-contains-cat
#+begin_src ...
1
vote
0
answers
531
views
How to run JUnit tests with lsp-mode and dap-mode, without build tools like maven
I have a Guix profile in which I installed for a beginner's java class a java environment as minimal as possible: openjdk 17, java-junit (which is JUnit 4), emacs-lsp-java, and emacs-dap-mode. I ...
1
vote
0
answers
354
views
emacs workspace/executeCommand with `vscode.java.resolveMainClass` failed
I'm trying to debug java in emacs.I'm running the command M-x dap-java-debug in emacs and I'm getting below error.
emacs workspace/executeCommand with vscode.java.resolveMainClass failed.
(error &...
0
votes
0
answers
113
views
Is there any way of making company show local classes inside a Java project?
I have a configuration for Java code on emacs that's the following:
(use-package flycheck
:ensure t
:config
(global-flycheck-mode))
(use-package company
:ensure t
:hook (after-init . global-...
2
votes
1
answer
372
views
Eglot spams the minibuffer in Java mode
I am essentially having this issue but for the java-mode. Eglot shows too many messages in the java files.
How can I fix this? I only wanna see the documentation and error messages in the minibuffer.
0
votes
1
answer
444
views
How to setup maven for lsp-java
I need to import gurobi.jar to my project to correctly view the flycheck's errors.
I have read Maven in 5 Minutes and How to add local jar files to a Maven project? but I am still not able to ...
0
votes
1
answer
158
views
Java-LSP freezes from Flymake error
I am very new to Java and have only been using an lsp for the past month or two. I have done some projects in Go, Python and Rust with lsp-mode and haven't had any problems. Now that I have been ...
0
votes
0
answers
73
views
lsp failing while requiring uninstalled packages
I have (I think) installed lsp and lsp-java. My java mode hook starts with
(message "Running my-java-mode-hook")
(auto-revert-mode)
;; Set up lsp
(require 'lsp-mode)
(require '...
1
vote
1
answer
232
views
How to set up K&R everywhere (1TBS) brace style in cc-mode?
I'd like Emacs to follow this indentation style:
struct Foo {
void bar() {
for (int i=0; i<10; i++) {
if (condition) {
// code
// code
...
2
votes
1
answer
2k
views
Java development on Emacs?
Is is exist good package for java development on Emacs?
Good... I mean to support:
Debugging
Code formatting
Code Highlighting
Help context
Maven support
Gradle support
and many others things
1
vote
1
answer
142
views
How to write evaluate java coding in Emacs file?
I am new to Emacs and I want to use org-mode to summarize the coding exercise and key points while learning Java. I am currently using IntelliJ to evaluate algorithmic coding questions I did on ...
1
vote
0
answers
389
views
enable flycheck/syntax checker for Java in Spacemacs
I'm a java developer and I'm beginner using spacemacs, I've configured .spacemacs file to java configuration.
Many functionalities works well, for example, a class recognition when I'm coding, but in ...
2
votes
1
answer
373
views
Java 15 Text Blocks in CC Mode?
Java SE 15 adds (finally) support for multiline string literals that start with """\n and end with """.
Has anyone updated java-mode (CC Mode) to recognize this construct?...
0
votes
1
answer
189
views
Where is the *meghanada-server-log*
I recently installed meghanada-mode from melpa to help with some Java I am writing. Mostly I like it. However, it has started showing the following messages (in my *Messages* buffer):
Error:...
0
votes
1
answer
538
views
Spacemacs Unable to use dap mode for Spring Boot web app
I am trying to set up a break point in my controller so that I can debug my spring boot web application within spacemacs. Can someone walk me through the steps on doing this.
The steps I have done so ...
0
votes
0
answers
234
views
Error occurs during Java: (wrong-type-argument stringp (require . info))
EDIT: Error is not present with Emacs 26.3. I will revist when Emacs 27 becomes a release.
Emacs 27.0.50
This error occurs when I load a .java file or read java code in an org-mode src block. How ...
1
vote
1
answer
2k
views
How to update lsp-java manually?
I'm trying to run a simple HelloWorld from Emacs using dap-mode commands dap-debug and dap-java-debug but prompted the error saying
lsp-request: No delegateCommandHandler for vscode.java....
2
votes
2
answers
5k
views
Are there any tutorials/documentation for lsp-java?
I have managed to install lsp-java according to their git Readme (https://github.com/emacs-lsp/lsp-java) and created my workspace.
Is there a better way (eg. in form of a documentation or tutorial) ...
1
vote
1
answer
786
views
Ensime plugin causes sbt error: "You must explicitly set JDK_HOME or JAVA_HOME"
Spacemacs: 0.200.7
Emacs: 25.3.1
sbt: 1.2.0
Java: openjdk version
"1.8.0_171"
.sbt/1.0/plugins/plugins.sbt: addSbtPlugin("org.ensime" % "sbt-ensime"
% "2.5.1")
...
1
vote
0
answers
121
views
Emacs doesn't use macOS's /etc/launchd.conf env variables
Emacs doesn't use macOS's /etc/launchd.conf env variables. I have the following there:
function addToPATH {
case ":$PATH:" in
*":$1:"*) :;; # already there
*) PATH="$1:$PATH";; # ...
1
vote
1
answer
1k
views
format java source code natively based on CodeFormatterProfile
Is there an emacs tool to format java code according to a Java Code Formatter Profile (xml) spec, such as the one below?
https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style....
2
votes
3
answers
1k
views
LIGHTWEIGHT Java Environment (not JDEE)
Is there a lightweight Java environment for EMACS? I have used JDEE in the past, but it's accumulated a lot of, ahem, features since I used it last, and just trying to set it up has consumed a couple ...
1
vote
0
answers
119
views
Constrain Eclim to java files
I am using eclim and I am loving it! But I had to disable eclimd-autostart because it keep trying to fire up eclimd when I pop a .js buffer.
Autostarting of eclimd is disabled, please start eclimd ...
3
votes
0
answers
50
views
How to specify the (sub)directory for source and compiled files when evaluating Java codeblocks in org mode?
I use Org Mode with Java codeblocks.
When I evaluate a codeblock the source files and the compiled files (*.class) are saved in the same directory as the Org file with the codeblocks.
How can I ...
0
votes
0
answers
101
views
use-package - load package depending on the OS username
I am not a Java guy at all, but I mess with it quite often for university reasons. I have used this awesome post by peter goldsborough to set up eclim. Which is nice! But this also requires a lot of ...
1
vote
1
answer
277
views
JDEE runs maven all the time
I am opening a Java source file which is part of a maven project. JDEE now runs maven once, which I can sort of understand. But whenever I move around in the file, it will trigger once more. Since it ...
0
votes
1
answer
1k
views
How to indent PHP code in PHP-mode?
I come from Java/Netbeans, and I can indent my Java code using alt+shift+f,
I have searched through this site and other articles, but I didn't find a good way to indent PHP.
What I found:
using ...
1
vote
0
answers
93
views
Eclim problems not being highlighted/problems not being shown in minibuffer
I know I have eclim setup correctly because everything else works, I.E I can do autocomplete, jump to definition etc. I can even see problems with eclim-problems. However, when I make a syntax error, ...
2
votes
1
answer
393
views
setting JDEE-server in emacs?
i've installed jdee from package-list it was elpa i think .. color highlight and indentation are working fine . but
when i run any command ( JDEE commands ) i get this message :
Customize ‘jdee-...
2
votes
0
answers
68
views
JDEE can not detect multi file
I have two files A.java (base class) and B.java (class). The class B succeed A. In file B.java, I compiled by C-c C-v C-c, then it can not detect file A.java with error message:
cannot find symbol
...
2
votes
1
answer
185
views
disable on-click mail sending in java mode
using spacemacs in java mode, moving the mouse over an email address displays in the modeline the text mouse-1, C-c RET: mail this address. And if I click on it, a blank email sending form is opened ...
3
votes
4
answers
255
views
How do I find the variable or lisp code controlling a face at a particular column?
For the longest time I have been ignoring a face change at column 80 in my Java code. The text switches to a pinkish color as shown below. Now it is sufficiently bothersome that I would like to ...
7
votes
5
answers
8k
views
Setting up Ditaa in Org-mode
I've been having trouble setting up ditaa to work in emacs,
I got my copy of the ditaa jar from here
And I've been trying to run this code block
#+begin_src ditaa :file hello.png :exports results
+-...
0
votes
1
answer
364
views
gud-break doesn't work with jdb
I successfully attach to my java app with emacs & gud, but gud-break doesn't work as expected: it runs only:
stop at :48
if the line number is 48. So even the class name is missing and the ...
10
votes
1
answer
1k
views
Which class or method or function am I in?
When navigating a source file with incremental search, I often find myself jumping into some context that is taller than the window. This raises the question: "Which class am I in?". Or, if the ...
2
votes
1
answer
398
views
How to have c-offset style correctly detect a Java constructor and change indentation?
Currently my team (non-Emacs users) indent java like so:
public DiskThresholdDecider(Settings settings,
NodeSettingsService nodeSettingsService,
...
23
votes
3
answers
22k
views
Suitability of Emacs as a Java development IDE
I'm making yet another attempt to convert over to Emacs. I'm a decent Vi user but have been using Eclipse for most of my development work for the past 10+ years (has it been that long).
So I did some ...
3
votes
0
answers
69
views
Java dependency injection
I develop Java programs in Emacs occasionally, and adding a dependency to a dependency-injected class is a common action.
For example, imagine adding the dependency Qux to the following class:
// ...
1
vote
1
answer
2k
views
Company eclim: cannot complete at point
What works
I have installed emacs-eclim and have it working in my Java buffers. For example, I can invoke eclim-java-refactor-rename-symbol-at-point or eclim-java-show-documentation-for-current-...
1
vote
1
answer
1k
views
Debugging and setting breakpoints in Java code built with Gradle
I am using Emacs (v24.4) for writing Java applications. I have created a Java library that I am building using Gradle (v2.2) and testing with Spock Framework where I have all my test cases.
I would ...