This is my own version of karel the Robot. The Janitor Robot that can only run un eclipse. My problem is when I open and i click run in a first time the robot moves according to the codes. but when i tried to edit the codes while the window is open, when i click the run button again it did not moves and need to close again.
This is my source code in the run method:
I have a janibot class that is implemented by a runnable and then. and i create its instance dynamically by this code.
Object tempJanibot = Class.forName(className).newInstance();
janibot = (Janibot) tempJanibot;
janibot.run()
where classname is the subclass of Janibot that is takingTurns in the screenshots.
It successfully created the instance of takingTurns class.
But I thought when i edit the code while the program is running and I click the run method the takingTurns class must be updated also but unfortunately it will not update and so I need to close again and click the run button.
What you are looking for is hot loading of the Java class. The default mechanism in Java is to load the class once in classloader reference and re-use it when required. So while Java application is running and if the class is recompiled, it will not pick up the new definition. If you wish to achieve similar functionality, you can look for solutions like JRebel or spring loaded.
"It's not a bug, it's a feature!" Eclipse cannot recompile your code while it is running and merge those changes into your currently running program. You'll have to restart the program each time.
Related
I've written a Java Agent in IBM Domino Designer, but I don't know how to run it. Whenever I click "Run Agent" pretty much nothing happens, it only says that
Started running agent 'unzipFiles|unzipFiles' on 08.11.2017 10:45:21
Found 0 document(s) that match search criteria
Ran Java Agent Class
Done running agent 'unzipFiles|unzipFiles' on 08.11.2017 10:45:23
But when I go directly into the class and click Run As -> Java Applciation everything works fine. What's the problem? It seems to me, that it even doesn't go to the JavaAgent class and invoke main method. I've tried to put Thread.sleep(99999) method, but the time of "execution" of this agent is the same - 2 seconds. How can I solve it?
The agent properties
Is there any way to debug it?
A Domino agent is not a java application. You don't need to implement the method 'main' but 'NotesMain'. And the agent class must extend lotus.domino.AgentBase.
If you create a new agent from scratch Domino Designer gives you all the boiler plate code. Just start from the line
//Your code goes here
I have an existing set of QTP regression tests that I wrote and have executed through several regression test cycles successfully. I have a JavaWindow that contains several JavaTables where I parse the table data into an array and verify it against the expected results in Excel spreadsheets.
In the current test cycle, the JavaWindow (which contained the JavaTables that I could read and verify) has now changed to a class of Window, and QTP sees this Window as simply one object. I can no longer verify the table data inside the window.
What may have happened that could cause the QTP class of the JavaWindow to change to a class of Window? No code changes have been made to this window, and I have verified that the Java versions on both my test box and app server have not changed and are valid for the current version of QTP.
Any insight into this issue would be greatly appreciated.
It sounds like the Java addin in QTP isn't working. There can be several causes for this.
QTP was loaded without selecting the Java addin in the addin manager
The test's Record and Run settings don't include your application
The Java application was opened before QTP (so QTP wasn't able to hook this application)
Along with the other answer, it might also happen, when you mess up your with Environment Variables. Lets say you installed StarTeam (it happened to me) recently which updates some of the existing environment variables set by QTP like JAVA_OPTIONS.
If it was working before & you could not figure out the issue, i would suggest you to repair UFT (using control panel options).
I have a JavaFX 8 desktop application and I'm creating an .app application bundle to distribute the application to Mac users. I use the Oracle “Self-Contained Application Packaging” tool to generate the bundle.
The problem that I have relates to the files associated with my application. I am associating the extension .wordy with these files. If I have the application open and I double click one of these files in the Mac Finder, my application receives an OpenFilesEvent containing the path to the file and everything works perfectly. If, however, the application is not open, double clicking a .wordy file in the Finder opens my application as I would expect but I never receive the event containing the path to the file that the user double-clicked on.
The file association is done in the Ant script for the Oracle “Self-Contained Application Packaging” tool, as follows:
<project name="VocabHunter Packaging" basedir=""
xmlns:fx="javafx:com.sun.javafx.tools.ant">
...
<fx:info title="VocabHunter">
<fx:association description="VocabHunter session"
extension="wordy"
mimetype="application/x-vnd.VocabHunterSession"
icon="${basedir}/icons/mac/VocabHunterSession.icns"/>
</fx:info>
...
</project>
In the Java code, I obtain an instance of com.apple.eawt.Application and then register the listener for the OpenFilesEvent as follows:
Application application = Application.getApplication();
application.setOpenFileHandler(new OsxOpenFilesHandler(listener));
You can see the full code here.
Does anyone know how to fix this so that I receive an event containing the path to the .wordy file even if the application was not running at the moment that the file was double clicked?
In the interests of completeness, I'm using the Oracle JDK 1.8.0_66 for Mac.
I tested with your code and also met this problem.
But when I used code directly in start(Stage primaryStage) method in to listen like this:
Application lowLevelApp = com.sun.glass.ui.Application.GetApplication();
lowLevelApp.setEventHandler {...}
I can get the OpenFilesEvent when first double clicked on file.
There is an entry in the bug database for this issue.
https://bugs.openjdk.java.net/browse/JDK-8187992
You probably call the application.setOpenFileHandler() code too late during the application initialization. Try calling it as early as possible in main() and see if that solves the problem. I am not sure exactly when Mac OS X passes the OpenFile event to Java, but if at that time you haven't prepared by calling application.setOpenFileHandler() then the event will get lost.
For future reference: getting the openFileHandler to work correctly can be very tricky. The handler is invoked from an event handler on the UI event thread, which means there is no guarantee that main() has completed when the handler is run. For best results, the openFileHandler should be set up using a static initializer, and main() and the open file handler should both invoke the same initialization code on the UI event thread, and the initialization code should be written to work if called more than once.
"Debugception!"
You may notice that within the first 15 seconds of this YouTube video (from 1:01:01 to 1:01:16), Markus Persson (aka "Notch", creator of Minecraft) has somehow managed to save/update an application and attach a debugger to it while it was already under the process of being debugged, supposedly all with a simple keyboard shortcut. The previously coded application somehow magically became the newly edited one, and seemingly without relaunching it or spawning a new process... It's possible that this is just some form of locally remote debugging, but something about it just doesn't seem quite right.
I've spent several days Googling and asking around on how he was able to do this, yet to no avail. I've found no such option under Eclipse preferences, and whenever I try to save & debug an already running application, it simply launches a separate instance of the newly updated application, side-by-side with the older, outdated one.
Am I missing something? How was this possible?
How was he able to utilize such an astounding, powerful debugging feature?
Thanks in advance!
Update
Okay, so this appears to be a standard feature specific to Eclipse.
Coming from a background in NetBeans and Visual Studio, I'm astounded that this doesn't seem to exist elsewhere (or at least in NetBeans!)...
This is a built-in feature of Eclipse. If you edit a method while the program is running in debug mode, it will compile the new method, and replace the old method with the new version. If some thread was already running that method, it will jump back to the beginning (AFAIK; this might only happen when the program is paused).
You don't need to re-launch the program or set any special preferences. Just edit and save, and the magic will happen.
Eclipse can't always figure out how to merge your changes into the running program - usually if you changed anything outside a method body (including the method's parameters or return type). In this case, you will get a warning dialog, with the option to stop the program, restart the program or ignore the changes.
I am a beginner using eclipse for java programming. Recently I downloaded certain source code online and ran it in eclipse successfully. I want to learn how it runs. However, I failed to find a way to monitor the progress during the program running. For example, if I run the application and click certain button in the application GUI, how do I know which class/method is called? In other words, how can I use eclipse to monitor the process of program running?
The general answer is to use the debugger. For example, set a breakpoint in some method and then use "Debug As" instead of "Run As" to run the application within Eclipse.
Here are a couple of tutorials / articles on using the Eclipse Debugger.
http://www.vogella.com/articles/EclipseDebugging/
http://agile.csc.ncsu.edu/SEMaterials/tutorials/eclipse-debugger/
http://www.ibm.com/developerworks/library/os-ecbug/
Put a breakpoint(double click the left side of the line) on your method to be debugged and debug your program.
Simply put breakpoints in the code lines you need to look and run the application in the Debug mode then it'll wait at the relevant code lines you need to check.