In web applications that run with Tomcat from Eclipse, for example, we can right-click on an element in the page and inspect it (with Firebug, for example), and we can see the element's ID, class, etc. If we have a JAVA Swing application that we run from Eclipse (right-click project ==> debug as ==> eclipse application), can we do the same thing so that we can see which method, for example handles that element, or whatever? Can we inspect a JAVA Swing element as it runs (from Eclipse)? I already checked swing-inspector, but I do not want it.
Thank you
I am sorry that I can not offer you a solution for Eclipse. If you can use Netbeans it includes a Visual Debugger feature. It is simple to use and it is integrated in Netbeans by default.
Related
I'm following a tutorial on using SOAP web services and for this i must edit my file WelcomeSOAP.java using design view, however design view is not available, only the 'source' and 'history' views are on the bar to the top; also if i go to view > editors they are the only two options. I have come across this question:
Netbeans design view?
However, both my laptop and computer are running netbeans 7.4 and the design view is available on my desktop, but I need to be able to use it on my laptop too. Does anyone know how to enable design view?
EDIT:
I have tried deactivating and reactivating the GUI plugin, and also re-installed netbeans, both of which did not work for me.
Tools->Plugins->Available plugins, search for 'GUI' if you need Then check: Spring framework for Java SE. It works for me on NetBeans 8.0.2
In the Menu Bar Go to -
View > (Check) Show Editor Toolbar
Done.
Alright i've found the answer. When you are in your source package, right click and there should be options for "forms"
search for 'web service' and make sure that 'Java Web and EE' is active
Open Java Application, then right click on "Source Packages" - "New" - "Other" - (Categories) "Swing GUI Form" - (File Type) "JApplet Form"
Job Done.......
(I tried thin with 8.0.2)
Hmm.. It might be because you're not using the latest version of NetBeans (I had the same issue). Get NetBeans 8.0.2 and reinstall the GUI plugin. it should work then.
You have to install the plugin named web services. You can find it in this path and search for it there in the search box in top right corner.
tools->plugins->available plugins
Tools->Plugins->Available plugins, search for 'web service' if you need
Then check:
RESTFUL Web Service,
SOAP Web Service.
It works for me
Error : "Design view cannot be rendered."
Below procedure worked for me:
Close the file that has the design view (Web Services folder -> YourService)
Close the netbeans
Open Netbeans
Open the file again
Make sure you have not deleted the ".Form" file (Thats's what I did while rearranging everything). It is the file that lets you edit the form in netbeans. I couldn't find how to recover.
Goal
I'm currently developing an application in Netbeans using the Netbeans Platform on Windows (a cross-platform solution would be wonderful but something hacky for Windows if required is fine for now). The application communicates with a native C++ DLL through JNA. The DLL sits in a specified directory which I cannot control or change - say C:\DLL.
The DLL itself loads some files for reading in values etc. but it does this using relative paths. So it requires the "current" directory to be C:\DLL. Again, this is something I can't change in this project. The DLL is something I have to communicate with as is (unfortunately).
Problem
For regular JAVA applications I've had the option in Netbeans to set the working directory of the launched application like shown below:
http://i.imgur.com/3HuQKS8.png
But in the Netbeans Platform framework/template there are no such options. For the most part it looks like Netbeans just makes the directory of the current file I have focused in the Editor pane to be the Current Working Directory.
So how do I go about doing this? I might be able to run the application through a shortcut that sits in C:\DLL but this doesn't help when I'm debugging the application through Netbeans.
I want to know how I can run/debug this Netbeans Platform application with the current working directory set.
Clarifying Netbeans Platform
The Netbeans Platform is an application framework of sorts. Has a pre-defined structure based on "modules" that interact to form the full application. The whole thing is hosted inside the Netbeans Platform environment which provides each of your modules with tabbed/docking windows. Kind of nice to develop larger applications.
More information here: https://netbeans.org/kb/trails/platform.html
I've resorted to using chdir as #technomage (I can't seem to upvote his/her comment with my current account status) has also suggested.
To do this, I used the following piece of code before I load up my C++ DLL through JNA.
NativeLibrary clib = NativeLibrary.getInstance(null);
int result = clib.getFunction("_chdir").invokeInt(new Object[]{"<PATH GOES HERE>"});
Source: https://www.java.net/node/643965#comment-821128
You can also check the result by checking the result variable. Should be zero if everything went well.
I am not quite sure why null works for NativeLibrary.getInstance. The documentation doesn't say anything specifically about this and I haven't been able to glean anything from the source here: https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java - But passing null does seem to get you the default libc or equivalent for your platform.
Note also that I had to add an _ (underscore) to the function name. This has to do with how function calls get mangled when compiled on Windows. As far as I know, this isn't required on other platforms, but I don't have the ability to test this right now.
Since I was unsure about whether my call was actually working, I did the following first:
Function f = clib.getFunction("_chdir");
This returns a function "pointer" f that you can trace/debug to see if you have a valid reference. Luckily, in my case, all I had to do was add the underscore as was suggested in the source link above.
After this call to chdir, the C++ DLL I need to access has been happily accessing files relative to the location specified in chdir.
I'm developing an application in Java using Pivot for the GUI elements, in the Eclipse IDE.
Since the end product is supposed to be an applet, I am wondering, if there is a way to launch the application in a browser through Eclipse during the development phase.
I don't want instructions on how to write an html page that loads the libraries and jnlp or something like that, I'm only asking if there is a way to automatically do all that in one-click-mode through Eclipse.
The Run Configurations in Eclipse support launching a Java Applet.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-launching_java_applet.htm
The Hello World tutorial page on Apache's website gives you the information needed to configure the applet.
http://pivot.apache.org/tutorials/hello-world.html
[Edit in response to comment]
Open the Run Configurations Window and add a new "Java Applet". That's what the first link was meant to indicate you are able to do.
The second link provides a snippet of how you're supposed to run applets using the BrowserApplicationContext, and it's quite specific in the values you provide (and map one for one to the Eclipse launcher values):
<applet code="org.apache.pivot.wtk.BrowserApplicationContext$HostApplet"
archive="lib/pivot-core-[version].jar,lib/pivot-wtk-[version].jar,lib/pivot-wtk-terra-[version].jar,lib/pivot-tutorials-[version].jar"
width="160"
height="80"
>
<param name="application_class_name" value="org.apache.pivot.tutorials.HelloJava"> </applet>
The Main and Parameters tabs should be the only one you're looking at.
I am working on an Eclipse RCP application with localization. A user should be able to change the language used in the application on the fly. A restart of the application should not take place during this language switch. It should also be possible to switch between languages written from left to right and languages written from right to left.
Is there a (good) way to solve this problem?
According to this thread:
Most of the eclipse libraries load up their language info on widget creation. If you change your locale afterwards you need to restart eclipse to have it take effect.
You could write that kind of dynamic behaviour into your own SWT program, however (when the locale switches, you'd need to call setText(*) on everything :-)
So this is not currently managed dynamically unless you program it yourself...
Other rcp/plugins application like Birt specify the same instructions (i.e. "Restart Eclipse" at the end...)
That said, a slightly different problem was set in this thread:
switch the language setting, restart, and then run in that language
I got it to work by reading bug 222023 and mimicking org.eclipse.ui.internal.ide.actions.OpenWorkspaceAction
I tried it manually:
added "-configuration #user.home/.myapp/configuration" to the launcher.ini
added "osgi.nl" to the users config.ini residing there and it worked.
Since I can access the config-Location via Platform.getConfigurationLocation() I guess that could be the way.
Note: adding "osgi.nl" to the webstart jnlp works too.
You would need to call setText on each widget, with the respective text. Since there is no text variable mapping on the widgets, you would have to do that completely manually as well.
What’s the equivalent of
System.Diagnostics.Debugger.Break();
in the Java world?
Purpose: I have a tomcat based webapp launched by a custom build tool and need to debug the application in eclipse. In the .net world the above statement when encountered will prompt the OS to attach a debugger and I can attach Visual Studio to debug. I am trying to achieve the equivalent in java with eclipse
Here's an excellent article on remote debugging using Eclipse. They even have a section discussing Tomcat.
Here's a link that I used to debug web apps on Tomcat. It goes through installing Eclipse, Tomcat and Java and then setting up Tomcat to run in Eclipse. Towards the bottom explains how to debug a servlet in Eclipse.
http://www.windofkeltia.com/j2ee/wtp-tutorial.html
In general the Java program cannot tell if the JVM runs in debug mode or not, and there is no way to from your program to say that you always want to start a debugger HERE.
You can, however, tell the DEBUGGER that you want to have a breakpoint at a given location, and you will then enter the debugger when the program reaches that spot.
EDIT: You will need to investigate your launcher to see how you can trick it to contain the options needed to enable debugging in the JVM. You may also see if jvisualvm can give you the information you need as it can attach to an unprepared Sun JVM.