I'm writing an application in Java that does some processing on arbitrary .java files. I'm using Eclipse, and when there's part of a .java file that it doesn't understand, I print out to the System.err stream:
System.err.format("Unable to resolve name %s (%s:%d)\n",
node.getName(), node.filePath(), node.getStartLine());
So it will print out something like this:
Unable to resolve name Foo (C:\project\src\Project\bar.java:63)
And the Eclipse console puts a link on the path and line part of the error. When I try to click on it, it says:
Source not found for C
I assume that's because Eclipse is only looking at source files in the project I'm running, not in the arbitrary .java file I'm processing. Is there any way to make it actually open that file and go to that line?
Unfortunately, the answer is no. Eclipse will only match the files against the resources in the workspace.
Related
I need to open certain files (.java, .js, .html ...) with eclipse but when I try to do it I get the following error:
"The default workspace is in use or cannot be created"
How can I solve? Thank you.
Usually you have to import projects to meaningfully use your files.
Otherwise, you just get a, for example, .java or .class file that you cannot do anything.
If you are importing an existing project, check this link: https://www.360logica.com/blog/how-to-import-a-java-project-into-eclipse-ide/
Another option is, copying and pasting your existing file in the workplace folder that eclipse points to. Then go into eclipse and create a new project with the exact same name. At this point, eclipse should recognize the project and show it in the left project explorer window.
I have my project/s on Eclipse with obviously my workspace/s. If for example I have the ide open because I'm working on a workspace I can not open external files. I would like them instead to open up in my current work area.
I try to execute a jar file in the command prompt, but I always get the message 'no main manifest attribute, in 2056751-0.0.1-SNAPSHOT-src.jar'. So, I guess I should edit the manifest file. If I check it in the command prompt with the command 'jar tf 2056751-0.0.1-SNAPSHOT-src.jar' I can see that there is a MANIFEST.MF file, still I cannot see it in Eclipse project view.
To partially answer the question asked, IF on Windows (which you didn't say and isn't the only system with a command prompt), a jar file is really a ZIP file underneath and Explorer in all supported versions (>XP/S03) can treat a ZIP file as a directory subtree, so just rename to have the extension .zip and open in explorer, go to META-INF, select MANIFEST.MF and open with plain-text editor of your choice such as notepad. However this may not allow you to edit; if so copy to somewhere writable like the desktop, edit, then copy or move back. Then rename back to .jar
Although the manifest file in a jar can be loaded from an actual file, usually it is created by the jar tool. If you want a jar containing classes to run from the usual file association on Windows use the jar tool with the e option as described in the man page or Windows version on the web and help message. However if your file name is accurate and this is actually a source jar, it will never be runnable by only changing the manifest and you need to learn how Java works.
I have a Scala application made in IntelliJ Idea 12. Although it should be pretty obvious, I didn't find any information about the location of a result (output) .jar file which is generated by IDE.
So what's the location?
Cmd + ; opens Project Structure in IDEA. Choose Artifacts and make one:
There you can see the line Output directory. Then click Build artifacts:
And here is it:
I'm using CDT plugin for eclipse for C/C+ development. But i'm not able to compile code it shows following error LINK : fatal error LNK1104: cannot open file 'C:\Program.obj'
What could be reasons?
One workaround would be to make sure to get your sources and generate your object files in a path with no space (not like "C:\Program Files (x86)\...")
The other workaround would be to check in the settings of the project if you can add double-quotes around any path defined. Check also the content of the .project file itself.
While debugging a large scale project, I use links in the log printout to jump straight to the relevant file and line. Alas in many cases I get the following pop-up:
XXX is not a valid line number in YYY.java
On the main sub-window there's also the following message:
The JAR file M2_REPO\org\apache\...\some.jar has no source attachment.
Of course I checked that:
M2_REPO (defined under Window\Preferences\Java\Build Path\Classparth Variables) points to the maven repository correctly
the path and filename in the message above is correct and the file exists
YYY.java has line XXX and indeed it is the source of the log message
What could possibly make eclipse mistake in this trivial task?
What other configuration might be set wrong?
Press Ctrl+Shift+R and enter YYY.java. Eclipse will then tell you which YYY.java it can see. Chances are that it sees more or other source files than you expect.
If there is just a single file, make sure it's the correct version. Maybe Eclipse mixes a new bytecode JAR with an old source JAR.
The maven error message means that it's missing M2_REPO\org\apache\...\some-version-sources.jar This file must be in the same directory as some-version.jar for Eclipse to attach the sources to the binary JAR.
If you have the sources, copy it there. If you don't have them, there is a chance that Eclipse can download them for you. Open the context menu for the project -> Maven -> Download sources ... wait ...
I just experienced the same issue. I was using the apache tomcat debugger and had the following line in the output:
SERVER: 2015 Jul 05, 13:11:58.311 (http-nio-8080-exec-4) DEBUG - (ForwardActionBean.java:41) forward
Clicking on the link in the output window gave me the error "41 is not a valid line number in ForwardActionBean.java"
The problem was: I had two projects open and each had a class called ForwardActionBean
The solution was: remove the project I wasn't working on from eclipse.
Hope this helps the next person that comes across this issue.
Also, it's important to make sure line numbers are being generated by the compiler (this is the default behavior so it is probably not the source of the problem). This can be checked by selecting window->preferences->java->compiler
Just simply restore your java compiler settings to default and uninstall your any decompiler add-on in your Eclipse, and the problem is solved!