Closed xufangda closed 6 years ago
Are you using the .jar as a library? Or import contents of the jar to modify them?
closing since no activity
i have the same problem, how to add the external jars to VS code?
@ismailashik what sort of project are you working with? Maven, Gradle, Eclipse?
eclipse java project
So if you added a jar dependency in Eclipse, reopening the same project in vscode should work, if it's a simple Java project. If it doesn't, please provide a sample project reproducing the issue
here is the sample eclipse project. i could not import this eclipse project with VS code. I have to use the folder source test_vs_code.zip
Works for me (after pointing to a json.jar on my machine). It even works in Atom.
Can you try opening this one (the jar is included in the project directory, so it's more portable)? test_vs_code2.zip
how did you point the json.jar in vscode?
check .classpath
this is what i get when i open the folder that you have sent.
this is NOT vscode-java's output!
Please disable/uninstall other Java Language support extensions, make sure you only have the one from Red Hat.
To launch and debug your Java programs, it's recommended you install Java Debug Extension for Visual Studio Code.
Now i get this error.
[Error - 3:09:45 AM] Nov 24, 2017 3:09:42 AM Invalid project description. [Error - 3:09:45 AM] Nov 24, 2017 3:09:42 AM An internal error occurred during: "Initialize Workspace". org.eclipse.core.internal.resources.ResourceException: Invalid project description. java.lang.RuntimeException: org.eclipse.core.internal.resources.ResourceException: Invalid project description. at org.eclipse.jdt.ls.core.internal.managers.EclipseProjectImporter.importDir(EclipseProjectImporter.java:96) at org.eclipse.jdt.ls.core.internal.managers.EclipseProjectImporter.lambda$0(EclipseProjectImporter.java:63) at org.eclipse.jdt.ls.core.internal.managers.EclipseProjectImporter$$Lambda$29/568268184.accept(Unknown Source) at java.util.ArrayList.forEach(ArrayList.java:1249) at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080) at org.eclipse.jdt.ls.core.internal.managers.EclipseProjectImporter.importToWorkspace(EclipseProjectImporter.java:63) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:100) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.access$1(ProjectsManager.java:94) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager$1.run(ProjectsManager.java:88) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5660) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5617) at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:82) at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:157) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) Caused by: org.eclipse.core.internal.resources.ResourceException: Invalid project description. at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:169) at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:53) at org.eclipse.core.internal.resources.Project.create(Project.java:263) at org.eclipse.core.internal.resources.Project.create(Project.java:247) at org.eclipse.jdt.ls.core.internal.managers.EclipseProjectImporter.importDir(EclipseProjectImporter.java:92) ... 18 more
that loading stuck on 28%
thanks it works perfectly
How can I add .jar file using maven dependencies. Well,I am trying to import itext library,as we add dependencies in eclipse I just add them in pom.xml but here is the problem raise and I am getting error that class Document not found and so on.
I solved this problem by doing following..
Why is it so shit to add a .jar in every editor out there. Should have been a simple text file with a absolute path on each line.
Hopefully you have installed the Java Dependencies extension. There is a .classpath file in the root of you project folder. Open it with vscode. It will look something like:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="lib" path="D:\opencv_2413\opencv\build\java\opencv-2413.jar"/>
`
add this classpathentry:
<classpathentry kind="lib" path="path to your opencv jar file, or any library\opencv-2413.jar"/>
Nice reference here: https://dzone.com/articles/visual-studio-code-for-java-the-ultimate-guide-201
It'd be so nice if you could just drop the file in your working folder and: right click > add lib to classpath ...
It'd be so nice if you could just drop the file in your working folder and: right click > add lib to classpath ...
I think @jdneo @testforstephen are working on something related to this idea. Would you guys share more thoughts?
Are you using the .jar as a library? Or import contents of the jar to modify them?
Hi,
How would you import the contents of the jar to modify them? I was able to import the jar as a dependency but the source codes aren't showing.
import the contents of the jar to modify them
Do you mean you want to modify the source code of the imported jar?
Are you using the .jar as a library? Or import contents of the jar to modify them?
could you just answer the question anyway?
I'm sorry to ask this silly question.
But I've been searching everywhere to learn how to import a jar package in vscode.
Suppose the jar file is in C:/java/lib/package.jar directory, how can I import it in vscode??
Environment