J-- Compiler Source Code Attachment - java

I'm reading a book right now, Its called: "Introduction to Compiler Construction in a Java World". So from their website you can download the source code of the compiler that one must use. -> http://www.cs.umb.edu/j--/download.html My problem is that I would like to follow the process of the compiler through debugging. But it doesnt work, because you have to attach the source code, which I tried, but it doesnt seem to work. I attached class files, java files, the jar, nothing works. So does someone know how to fix that problem?
Edit1: In eclipse
Edit2: Maybe this helps to understand my Problem better-> http://postimg.org/image/9pd2gyle7/
I wanna see what happens in the compiler process. But I cant see the main class, even though I have the main source code :S

When you say, you did attach sources, make sure to define a source attachment in a way that Eclipse understands. If that's what you tried, more information would be necessary to tell why it didn't work.

Related

File not in same subdirectory or sourcepath?

I am new to Java and this is my essay to pass java. I found a template that I want to test, but the error is too strange for me to understand.
I must work in Netbeans ID 13 and the picture shows it all. But to me... I have the idea that I have everything on the same place. See here
I hope someone can help me to get on the right track.
Make sure the package and the directory names are both in lowercase. So 'com.mycompany.test1' not 'com.mycompany.Test1'. If the java source files are in the same package, then an import is not needed.
There might be something wrong within Options.java too. If so, please share the source code of it.

Can't edit java code-file is somehow empty

Hopefully this has a trivial answer: I have a java file which I wrote and edited a while back, but at some point I tried to open it recently and it says it is 0kb and no code is displayed in the IDE(i tried more than one). What is really confusing is that it runs perfectly from command line. It was just quite a small GuiApp, and all the class files are still there. Any help would be appreciated
You can decompile the .class file and you will see your code.
Fair warning, this will be 'compiled code' so expect to see many changes in your code as the compiler has the liberty to optimise code where it sees fit. You may see it use the StringBuilder class for example where you simply concated a couple of strings, etc.

Run main method of a class in the test folder

Tried to google but got hundreds of unrelated issues regarding testing. I guess I'm missing a crucial keyword to reduce the number of hits to something that is relevant for me.
I have a class in src/test-integration/java which i need to run, since it is a tool for extracting test data from an database. It's basically just a little script in the main method.
However when I try to "run as java application" in Eclipse it says: Error: Could not find or load main class x.y.z.MyClass
I know it has worked before, but not sure how I got it to work.
Sorry for any missing information, please feel free to ask for more.
Any ideas of what I'm missing?
Added the whole full path to the java class in the Java Build Path properties in Eclipse and deselected "allow output for source folders" and selected it once again (don't know if that did something, but I include it anyway).

can you create java file from the class file? Decompile

I recently created a project in Netbeans using VirtualBox on which i installed windows XP (Not activiated)
My Windows required me to activate and would not allow me access to my files on the computer before i activate it, i stupidly went and uninstalled XP and reinstalled it, thinking i'll have access to all the files from the JAR file i created
I want to know if theres any way i can use the class files of the project i created, to create new java files so that i can edit the code in netbeans ??
Please if anyone can shed some light on this topic, if its at all posible to gain access to the forms java content i created. Im new to programming and this is something above my knowledge (i hope this makes sense)
If not possible please let me know what an absolute idiot i am, so that i can start re creating the project from scratch ... Sigh, and thank you
A jar/class file is compiled bytecode that is not human-readable... but with Java it is easily converted back. Look into a program like JavaDecompiler.1 This is not my program but I use it and I find it workable for my needs.
1 If this is considered spam I'll gladly invalidate the link.
As a sidenote: You are lucky that its Java. In many other languages like C++ that would hardly be possible. The difference is that Java does not compile the source code to machine code. That step is hardly reversible since for example all variable names are lost. Try to understand a non-trivial piece of code without helpful variable names...
Java instead compiles the source code to byte code which then is interpreted by Java on runtime. That byte cold holds way more information about the original source code than machine code.

Eclipse plugin "Operation not enabled"

I'm struggling with Java Refactoring - I need to write an Eclipse plug-in which will refactor some code. It's really difficult for me and it would be way easier if I could follow working code step - by - step. The only alike example I could find is a sample Introduce Indirection.
Unfortunately I cannot make it actually work. I get "chosen operation is not currently available" information anytime I try it.
I've imported code, "Run As -> Eclipse App" and than tried to use Introduce Ind. from Eclipse Articles. What am I doing wrong?
I'll be happy with any help :).
Check your handler class for isEnabled() method. I suppose when creating new handler the default value for this method returns false. That can be the issue.
You should be able to get that example (as written) working, or perhaps you need to open a bug. When you start their example in Run As, is there any errors in your error log?
Something else you can try is to look at some of the workbench refactorings. See org.eclipse.ltk.internal.ui.refactoring.actions.MoveResourcesHandler which sets up the move resources refactoring, and http://wiki.eclipse.org/FAQ_How_do_I_find_a_particular_class_from_an_Eclipse_plug-in%3F if you need help tracking down the SDK classes using CTRL+SHIFT+T
I've managed to run it. For others who'll face the same problem:
Check the basics:
Remember that you can chose only one method and:
It must exist in the model (http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/IJavaElement.html)
It must not have any errors
Must not be a constructor
Must not be connected to annotation declaration
And:Select a Java method in the editor outline or the Package Explorer
And it gets obvious :)
The action handler class should be impediments with related interfaces (Check for error console for identify what are the missing interfaces, most probably this would be 'IActionDelegate').

Categories