Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Newb compiling question?  (Read 2108 times)
0 Members and 1 Guest are viewing this topic.
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Posted 2011-08-21 16:47:04 »

I was watching Notch's lifestream for ludumdare and during it, on several occasions he seemed to edit his code live, and it appeared to change things in the game window without having to stop / recompile?

Is this possible/  if it is, is it only possible for certain types of modification/changes?  adding/remove of a system.out.println and perhaps a modification to a if or for loop?

Or was my eyes lying to me and I just didn't see it properly?(if not,  how do you set that up?)

"Experience is what you get when you did not get what you wanted"
Offline counterp

Senior Member


Medals: 11



« Reply #1 - Posted 2011-08-21 17:06:56 »

JRebel does that (from experience, buggy, I think there was an issue with anonymous classes? that was a few years ago), might be others
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #2 - Posted 2011-08-21 17:12:04 »

Yeah JRebel is a plugin for Eclipse.  I will try it out and see if it fits my coding style as I think it might.  Thanks for the heads up


"Experience is what you get when you did not get what you wanted"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #3 - Posted 2011-08-21 17:21:23 »

Eclipse will do it as standard for some changes if you run from debug mode instead if just run.

Offline xsvenson
« Reply #4 - Posted 2011-08-21 18:31:25 »

JRebel is needed for class or method hotswaping. JVM however can hotswap method body by itself, with some restrictions and yes, debug mode is needed for this.

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline ra4king

JGO Kernel


Medals: 341
Projects: 2
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2011-08-22 04:03:44 »

@OP
What you saw was Notch using the JVM with debug mode on. This allows him to edit method bodies in as soon as he hits Ctrl+S (to save the file) it compiles that method and updates it in memory during run-time. Your eyes do not lie Wink

Offline Skarion

Senior Member


Medals: 2
Projects: 1



« Reply #6 - Posted 2011-08-22 12:52:38 »

Eclipse will do it as standard for some changes if you run from debug mode instead if just run.

How? Started in debug mode and updated text within a JLabel (or changing the background color) and it's not shown when ctrl+s.

Are there restrictions, do I need JRebel for such changes or have I missed something?
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #7 - Posted 2011-08-22 12:56:50 »

For the normal debugger to work the method needs to be executed after the change, so changing a JLabel text would have to happen in a code execution that happened after you saved the file. It doesn't unwind every call since the application started.

e.g. If you set the label text to be the seconds since the application started, and called the method that changes the text in a loop in your code, changing the method to display some other text, the next call to that method would get the new string displayed.

I'm guessing what ever you saw change in the livestream was something executed by a method called in the main game loop.

Endolf

Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #8 - Posted 2011-08-22 19:53:06 »

I am just trying to test this out

I am displaying some text on the screen
While in debug mode(I am pretty sure I am?) I tried changing the x/y coordinate of a
1  
g.drawString("test",300,250);

Its obviously calling drawstring every frame, so I am confused?

and I have no luck, am I missing some setting or something special?

I run eclipse, and click the little debug icon in the top?

"Experience is what you get when you did not get what you wanted"
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #9 - Posted 2011-08-22 19:54:32 »

do you do that in a loop like I suggested?, or is that drawn once?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #10 - Posted 2011-08-22 20:02:15 »

Its in a loop

I managed to get it to work by calling to compile a new debug(I close the new one)

and the "existing one" is updated. But it won't update unless I run debug a second time

Is there like an auto-update or a setting I need to configure so it automatically pushes out the saved file?

"Experience is what you get when you did not get what you wanted"
Offline Cero
« Reply #11 - Posted 2011-08-22 20:03:52 »

switch to debug mode, run in debug mode F11 / the bug button

change something, save file CRTL+s, then change appears in game

thats how I do it.

Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #12 - Posted 2011-08-22 20:05:11 »

switch to debug mode, run in debug mode F11 / the bug button

change something, save file CRTL+s, then change appears in game

thats how I do it.

I do exactly that, it only updates if I click the bug button a second time after saving(2 instances are now running, but even the old version shows the saved changes)


Edit: Found the solution

Under "Project"
make sure "Build Automatically" is turned on or else it wont work.  Once I enabled that, it all works good now!


"Experience is what you get when you did not get what you wanted"
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!