I've been bitten by this old bug/missing feature in Java:
http://bugs.sun.com/view_bug.do;jsessionid=b2ac8ea11f05c16d948e24d36fb5?bug_id=4673406
The thing is that the "Properties" button in Java's standard print dialog is seemingly always disabled on Windows. The button is only enabled if PrintService.getServiceUIFactory() returns something that isn't null. Unfortunately Win32PrintService instances always return null. Always.
By googling, I discovered that you can invoke Windows' own print properties dialog thingy by calling rundll32:
rundll32 printui.dll,PrintUIEntry /e /n "name of printer here"
I'm hoping I can use this to circumvent the bug/missing feature in Win32PrintService. However, I don't know how I can query the PrintUIEntry-dialog for the user's choices.
In other words, how can I get a result of the above rundll32-invocation? (If I have to write something in C/JNI and use the Windows API directly, so be it. I'd rather not, though.)
Or is there a better way to solve this problem?
rundll32 does not give you any return value, its exit code is always zero.
I think you'll have to find another way.
Related
When I type code in Sublime say, I just need to start with the first few letters of some variables and it would come up with a list of possible existing variable names that match what I just typed. But in Eclipse, I don't know how to realize this. In the preference-java-editor-content assist, I found this auto-activation pane and according to some other posts, I'm supposed to change the auto activation triggers for java. However this is how my default setting looks like. I don't understand the dot over there. Also I'm not sure if that's the right way to approach my problem?
Can someone help me out? Thanks!!
The auto activation will give you suggestions about fields and methods that are available. For example if you start typing in
new Object().
then the IDE (Eclipse) will give you suggestions (after 200ms from the "Auto activation delay") of toString(), equals(), and other methods.
If you just want to use plain auto-complete, I tend to use the shortcut CTRL+ Space (The spacebar key). So if I want Eclipse to auto-complete a method name for me (say the method is reallyLongMethodNameIDoNotWantToTypeOut()) I'll type in
reallyL press CTRL + Space and Eclipse will fill in the rest for me.
I have a script in Marathon, a Java Swing test automation tool using Jython or JRuby, that plugs in a value to the application under test; however, it doesn't plug it in sometimes. It is very sporadic. I tried to wrap the setting of the text values with an until loop, but that even sometimes doesn't work. The code looks like this:
until get_component("foo").getText() == "blah" do
select("foo", "blah")
end
get_component("") is a function that returns the Java object. After that I'm pretty much doing straight Java so the .getText() works just as it would in Java. Select is also a Marathon function that simply selects your foo object and plugs in the blah value. Therefore, all my code is doing is waiting until the "foo" object has "blah" text value and once it does then it moves on.
The problem that I have is that sometimes the application doesn't hold the "blah" value. I considered that it was a bug, but when I do this manually I can't recreate the problem. It simply plugs in the value as I would expect it to.
Has anybody else ever ran into this with any other scripting tool? If so, how did you overcome it?
I was able to get around this by putting a wait_p("foo", "blah") immediately after select("foo", "blah")
select("foo", "blah")
wait_p("foo", "blah")
This basically forces the application to wait until the foo component has the blah text before moving on.
I know there is a Ctrl+Space dialog box that show the methods options that I have.
But if i have a method that I not fully remember the name of it and I remember only a part of the name.
For example: There is a big static class which contains tons of methods starting with "add"
add1_Buffer, add2_Render, add7_Function and so on..
now I don't remember the fully name but i remember only "Buffer".
so I want to type "buffer" press Ctrl+Space and get the "add1_Buffer" method and all the names
that contain the name "buffer" in it.
Edit:
By the way, i need it on the OpenGL api where there are tons of functions and i am not familiar with all of them i know only keywords, I was searching for something like in visual studio that is really fast and easy.
If you start typing the a in add1_Buffer and then an upper B and then press Ctrl + Space you will find the correct method.
You can then continue writing the word Buffer if there are more methods starting with add and then having an upper B.
This means that you'll have to remember at least the first part of your method but hopefully you do.
Add the CodeRecommenders plugin to your installation. That has a subwords completion, which the normal JDT code completion does not have.
Use search. From the Search menu at the top of the window, select "Java Search". You can limit your search to methods and use wildcards to search for *Buffer* if you know that Buffer is in the method name.
The shortcut Ctrl + O gives an outline of the current source. So you can view and search all your methods in your current class. Use wildcards when needed.
This merely meets you req: alt+/, just a replacement for ctrl+space
Currently there is no direct way to do that in eclipse. But i found these are helpful. here
This post resembles your's look at it. Similar one here
I'm using a CreateProcess call within a C++ program to execute a JAR file that runs a Java Swing GUI application. All works fine with the exception that the Java app starts off minimized and I want it to start with the window displayed. Here's the relevant code snippet:
// Construct the command string to be used for the CreateProcess call,
//including a parameter string
sprintf(cmdStr, "javaw -jar \"AppDir\\App.jar\" %s", parmStr);
// Create and initialized startup-info structure for use with CreateProcess call
STARTUPINFO startInfo;
ZeroMemory(&startInfo, sizeof(startInfo));
startInfo.wShowWindow = SW_NORMAL;
startInfo.dwFlags = STARTF_USESHOWWINDOW;
startInfo.cb = sizeof(startInfo);
PROCESS_INFORMATION procInfo;
ZeroMemory(&procInfo, sizeof(procInfo));
if (!CreateProcess(NULL, cmdStr, NULL, NULL, FALSE, 0, NULL, NULL, &startInfo, &procInfo))
{
MessageBox( dialogOwner, "Create Process Error", "Application not instantiated", MB_OK);
}
According to the MSDN literature, setting the wShowWindow flag to SW_NORMAL and dwFlags to STARTF_USESHOWWINDOW ought to do the trick but some of the comments I've read in this and other forums imply that sometimes those flags are ignored (e.g. for console apps) so I was wondering if that was the case here. For the record, I've had this problem before then it went away on its own and now it's back after I made some code changes. But I wasn't setting any flags in the startupinfo structure before, so I was hoping to achieve some consistency in behaviour by doing so. Any tips or pointers would be appreciated...
Sheldon R.
Okay, I've been working on a solution to my problem and I'm finally ready to talk about it, since it appears to be working :) I call my Java app one of two ways: either by popping up a dialog box first to collect login credentials, or by calling the app directly using saved credentials. For the login-dialog case, I call CreateProcess with the parameter "javaw...", whereas the saved-credential case appears to need "java..." to avoid the app starting up minimized. Aside from the difference in the parameter string, everything else about the CreateProcess call is the same. I don't know why I would use "java" in one case and "javaw" in the other, but since it's working, I won't question it :) But, of course, if someone wants to enlighten on the subject, I'd be happy to learn more. Thanks to #Jim Garrison for the suggestion, even if it wasn't ultimately the solution to my issue...
Sheldon R.
This is an update to my previous answer: The reason I had to call my java applet two different ways (i.e. "java" or "javaw") depending on the context, had to do with a bug in the C++ application from which I was calling my applet. The reason I know this is because a few months after fixing my issue, a newer version of this application was released, and this version didn't have the underlying bug, which essentially caused a new bug in my applet due to the "java" command doing what you'd expect i.e. instantiating a console window in addition to the applet window, much to the surprise of my business users :). So for the new bug-free version of the C++ application, I call my applet using the "javaw" command regardless of whether or not a dialog box is instantiated first to enable the user to enter login credentials...
Sheldon
I want to change the type of a variable from String to int, can we use Eclipse to refactor?
There's no out of the box refactoring tool that does it as far as I know. The reason probably is that strictly speaking this isn't refactoring: refactoring is a change that doesn't affect the behaviour of the code, but this change definitely does.
Unless you're using reflection, the easiest way to make this change is to change the field first, then watch the bits that turn red, and work your way through them. (You'll get a cascade of errors, pieces that you fix will cause other pieces to go wrong, but eventually you'll get o the end of it.)
I know this isn't really the answer you wanted but if you follow this pattern (deliberately break the code first, then correct errors that arise), it doesn't take long.
If you do have reflection in your code though, then you have no other option than to go through every single file that uses reflection and check whether it would be affected by your change.