Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't recognize imports in classpath on a simple project #93

Closed
mdacach opened this issue Jun 11, 2020 · 9 comments
Closed

Doesn't recognize imports in classpath on a simple project #93

mdacach opened this issue Jun 11, 2020 · 9 comments

Comments

@mdacach
Copy link

mdacach commented Jun 11, 2020

coc-java doesn't seem to recognize my $CLASSPATH variable.
https://algs4.cs.princeton.edu/code/
I followed these instructions to set my classpath.
If I do :echo $CLASSPATH inside vim I get everything correctly, if I compile anything from the classpath it also works as expectedly. But coc-java does not offer completion regarding the classpath files and throws errors at every import from it.
This is a simple one file, not using anything.

@chemzqm chemzqm closed this as completed Jun 11, 2020
@chemzqm
Copy link
Member

chemzqm commented Jun 11, 2020

Should be problem of your language server, checkout https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

@mdacach
Copy link
Author

mdacach commented Jun 11, 2020

I'm sorry could you help me some more. I didn't find anything wrong with the output.
Do you know how can I see what classpath the jdt.ls is using? or if I can change it with some command?

That's my relevant part in the code:
import edu.princeton.cs.algs4.WeightedQuickUnionUF;
That is the settings it shows (I tried adding the classpath to the vmargs):
https://pastebin.com/W1kcnSKb

And this is the error part:
https://pastebin.com/z9CtsPta

It has a lot more lines but I don't think they are relevant, maybe this initial part here that has the errors too:
https://pastebin.com/Xy7tMGZW

@mdacach
Copy link
Author

mdacach commented Jun 11, 2020

Any help would be greately appreciated. I don't know my way around this stuff and couldn't find relevant information neither at the eclipse jdt page, or the vscode-java or anything

@mdacach
Copy link
Author

mdacach commented Jun 13, 2020

Update: jdt will in fact not recognize your env classpath.
To use jars from libraries you need to update the java.project.referencedLibraries
Like this: redhat-developer/vscode-java#1196 (comment)

@you-n-g
Copy link

you-n-g commented Jul 19, 2020

@mdacach
I have similar issue.
I've set java.project.referencedLibraries in coc-settings.json .
image

But it still raises the unresolve error.
image

Did you have similar problems ever?

Thanks!

@you-n-g
Copy link

you-n-g commented Aug 7, 2020

My problem is solved by configure the .classpath
image

@vcavallo
Copy link

vcavallo commented Mar 9, 2021

Same issue here for me.
I've also tried configuring a .classpath file - no help.

@uwla
Copy link

uwla commented Jun 28, 2021

My problem is solved by configure the .classpath
image

Where is this file you have changed?

I tried changing the .classpath files in ~/.config/coc/extensions/coc-java-data/*/*/.classpath, but after I change them and try using vim the changes are discarded and the files are the same as before.

@uwla
Copy link

uwla commented Jun 28, 2021

I can't get the libraries of Princeton algs4 into working even after adding the path to the java.project.referencedLibraries

"java.project.referencedLibraries": [
  "/home/andre/.local/share/algs4/algs4.jar",
  "/home/andre/.local/share/algs4/lift/lib/algs4.jar",
  "/home/andre/.local/share/algs4/lift/lib/introcs.jar",
  "/home/andre/.local/share/algs4/lift/lib/stdlib.jar",
]

Did any of you were able to get it working?

UPDATE: After migrating from vim to neovim it worked very well! The issue is that coc-settings.json must be under ~/.config/nvim and it seems to only work with neovim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants