Testing/Changing java sources at runtime - java

On that video: Coding with Notch we can see how Notch makes changes to Minecraft code and can immediately see the changes in game. I think that is very efficient and I would like to know how he does that!

Three Things
He is using the same workstation, He is just extending his screen.
Debug mode in Eclipse with breakpoints in those functions that are
most likely to be called in every actions in the game.
Eclipse emulators to run jar files. Similar to apk emulators

Related

How to debug Java code in IDE (Eclipse, Spring Tool Suite) like Visual Studio?

First of all, I know my question is not a good question, I should say sorry for my this question, but this question confused me for a long time.
.Net/Visual Studio: I am coming from a .Net background. When I develop a project, I and my team are using the Visual Studio. When I debug the server side code (C# class code), it is very convenient since I use Visual Studio. I set the breakpoint, then I hover my mouse above the code, I can see what is the value of a variable or array values of a variable, so I can quickly know what is the value of a variable.
Java/Eclipse/Spring Tool Suite: When I was a student, all my courses are using Java with Eclipse, including course assignment and projects, and I found it was not convenient for debugging. Because I need to go to a debug mode, then I need to see a separate Windows within Eclipse, which shows the value of a variable in each row, this is not very efficient way to debug compared to debug in Visual Studio.
Now, I am going to develop the project using Java. This project is based on Spring framework. Then I found many people are using Spring Tool Suite, so I am going to use this IDE to develop my project.
My question is: Can we debug Java in an IDE like we debug in Visual Studio? What about debug code in Spring framework using Spring Tool Suite? Thanks.
Update:
All right, . I am testing this easy java program in Eclipse. I set the breakpoint, then I click "Run" -> "Debug", then I open a debug perspective. In the past, I only can see what is the value for variable a and b in Red Circle 2, but now, look like recently, when I put my mouse on variable a and b in Red Circle 1, I can see its value immediately? If yes, when this feature added to Eclipse? I am quite sure we cannot do so in Eclipse in the past.
Once you are actually debugging an application, you can hover over a variable in an open editor for the selected stack frame in the Debug view and see the variable's value. This is a long available feature.
You can also drag a view, using its title bar, out of the main window to create a new window if you want. I don't think this is heavily used, and may not work correctly with multiple screens, but it's there.
You're drawing a line based on IDE settings. Most likely, you're running in debug mode in VS even though you don't explicitly say it. That being said, your question is basic; of course, you can debug Java like C#.
Yes, of course, you can debug java code in Eclipse. Set a break point to the line you want to debug and select an object/variable/whichever and inspect it or add to watch.

Can Eclipse run a single instance only of a project?

I usually develop mobile apps for iOS and Android and I am used to launching projects repeatedly without asking if another instance is running or not, since the simulators will handle this for me.
When I use Eclipse to develop desktop apps, I face this problem since running multiple times the same project will result in multiple different instances. I would like Eclipse to be able to kill the previously-opened processes before running the new one. I've found this question, but this one addresses the problem to let a single instance of a Java application run, but this is not quite the point. I do not care if the final release will run one or two times, I just want to be able to run a single instance when developing, seamlessly like Xcode or Eclipse for Android do. Moreover, that solution will popup an alert when running the same project twice, but that's not a solution for me. Kill and run, that it.
Is it possible to change the run configuration of the project to achieve this without changing the source code, or is this achievable with a plugin or whatelse? I would like to find a completely automated solution that could make me work as if I were under Xcode.
No, it is not possible to change the Eclipse run configuration so that Eclipse stops existing instance before running new instance.
As an alternative, you might try setting a keyboard shortcut for "Terminate" action.
What is the short cut in eclipse to terminate debugging/running?
Is there a keyboard shortcut for stopping the current console in Eclipse?
As a general solution to this, try:
Goto Window->Preferences, search for Launching.
Select the "Terminate and Relaunch while launching" option.
Press Apply.
Not sure if it would work while developing Android (not very common in Eclipse now), but good option to know.

Java Real-time debugging (gaming)

In this video :http://www.youtube.com/watch?v=BES9EKK4Aw4
Notch (minecraft's creator) is doing what he refers to as 'real-time debugging'. He's actually modifying the code and plays with the game at the same time without recompiling everytime.
Does anyone know what this is called or where I could get more information on how to achieve this? I've been looking around without any success!
Regards,
Erwald
This feature is called "hotswapping" and is supported by certain JVMs. The Eclipse IDE debugger is capable of hot-swapping your code in the debug (F11) mode. Eclipse can also auto-build your project once you save a modified file (AND hot-swap when running a debug build). Notch seems to be using exactly this technique.
some IDE s are doing this ie: eclipse, netbeans, intellij idea etc.
however some changes requires recompiling (method addition or deletion etc.)
and what he using is probably eclipse.

Droid programming with Eclipse in Java

I have a Neatbeans application, that works well and runs well so I want to move it into Android. So I am taking code snippets and moving it into Eclipse, and into a default made droid class. (which compiles, loads, and displays on the virtual device)
The problem, is that a few things that used to "import" into Netbeans, won't in Eclipse, or I am just doing it wrong, not sure.
Usually in Neatbeans I hit "import such and such class" and then it all compiles fine and no red errors appear in the code. In Eclipse, it is not giving any import option to some features, examples are..
DefaultModelList
HTMLUnitDriver/WebDriver (Selenium's program)
JOptionPane
And I am guessing some more will eventually pop up in the future.
Does Eclipse not support those options or something? Or is it Android that does not support those options?
Can someone tell me how to work around those issues, with their respective problems please?
The program itself is a mobile chat application, that will basically be a mobile version, of a chat that already exists on the web. Pulls chat feed data, lets you post chats back; basically the same thing as the chat on the website, but accessible from your smartphone.
Your problem is not with NetBeans vs. Eclipse. It sounds like your app uses the Java UI Framework Swing, from which you have JOptionPane. Swing is not available under Android, and anything that uses Swing will have to be extensively recoded to use the native Android UI instead.
Your app may use other libraries that aren't available in Android, as well.
Eclipse does support those options (press ctrl-shift-o). The problem is most likely the transition to Android -- lots of items change names. The Android native item to use is not JSpinner but Spinner, etc.
Also: In Android most GUI work is done with layout .xml files, a bit different than plain Java programming.
TLDR: you're conflating multiple issues. Eclipse can even import a Netbeans Project directly.
Is Eclipse a strong requirement for you? If you love NetBeans and everything is working, why not to continue with it? I believe you can develop for Android in NetBeans too...
http://binarywasteland.com/2011/07/install-netbeans-android-sdk/

How can I run an app's source code that I got from the Android source code?

For all of you android devs out there that have the Android simulator running on your comp, you know that there are a few built in apps that are already installed on your 'phone'. I had an idea for an app that would utilize a function that is already being done in the spare parts app that comes already installed.
I went on to the android developer site, dug through the source code files, and found the spare parts app, and am now trying to set it up so that running it from eclipse on my machine actually runs the app in the simulator. In other words, I want to be able to make changes to and adjust some of the things in that app for my own needs. But it won't compile, because of a number of different errors.
How do I get that source code running on my local machine? Is there some special trick that I just dont know about? I thought that if I could get the source code than the rest would be easy, but it isn't being too easy.
Not knowing what the error is, it is hard to say. But there are some tricks. First, you want the entire spare parts app in Eclipse, not just the code you are interested in running. Second, right click on your project, and go down to the "Android Tools" menu. Then click on "Fix Project Properties". Do a clean on your project and hopefully that will help.

Categories

Resources