#Can I import source files?

1 messages · Page 1 of 1 (latest)

obsidian belfry
#

if I have a library as a jar file - and decompile it using cfr or fernflower - can I then still import the source files using the same syntax as I would when it was still a jar? I.e. import com.hypixel.hytale.protocol.GameMode;

Im asking because Im trying to get intellisense in VS Code to follow referenes inside the jar. By default, I can ctrl click identifiers from my files into class files in the jar; but usually it doesnt let me do the same within the decompiled source of those class files.

So... I figured, maybe if I first decompiled the jar into a directory that could get resolved, but I cant seem to figure out how, or if I can just import these source files in the smae way I would a .jar

Addionally, being able to navigate java files using tools like file explorer as opposed to having to use specialized tools to navigate the .jar is a + for me.

rapid sparrowBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
If I have a library as a jar file - and decompile it using cfr or fernflower - can I then still import the source files using the same syntax as I would when it was still a jar? Im asking because Im trying to get intellisense in VS Code to follow referene

Yes, you can import source files in Java. However, you cannot import the decompiled source files in the same way as a jar file. Once a jar file is decompiled, it may not have the exact structure or format as the original source files.

Useful links:

  1. Decompiling Java Classes
  2. How to Decompile a JAR File
  3. Importing Source Files in Eclipse
obsidian belfry
solar tartan
#

why not just write code and compile it yourself and put it in a jar?

obsidian belfry
#

Sorry I forgot to say, when doing the "real" compilation, I can still use a jar - my goal here is just to get intellisense to use the source files

#

If its possible at all that is

#

If Im reading https://www.geeksforgeeks.org/java/packages-in-java/ right, it seems the answer to my question is yes...

#

so I guess Im experiencing some issue with VS Code/project setup

obsidian trail
#

Unless you're trying to edit the source files from the decompiled code

obsidian belfry
#

no, I just want them for browsing/intellisense

obsidian trail
#

Yeah then it should be supported

obsidian belfry
#

alright

obsidian trail
#

Vscode for Java is a bit rough to configure still

#

And there are two different plugins

obsidian belfry
#

Im using the plugin by redhat

#

or well, I got the extension pack by Microsoft, which includes "language support for java by RedHat"

obsidian belfry
#

or is extesionpack w redhat the go to?

obsidian trail
obsidian belfry
#

Yeah I just saw, I will test it as well

#

Do you think I can use either of these settings to add source paths?

odd hearth
#

Ideally you stop using the IDE to build your project and start using gradle or maven. IDE's get updated over time and old projects WILL break.

obsidian belfry