Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!

Chris Shepherd

Ranch Hand
+ Follow
since Jun 27, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Shepherd

Since it's mapped, you can just use command line commands to move the files. Here's some of mine for linux.

11 years ago
What about W's solution but do a straight add on all the values? if the two arrays add up to the same thing then consider them identical. Sure there's a possibility of a false positive, but if the arrays are as large as you indicate and you are using up to 5 decimal places, the chances are slim that you would get the false positive.

Paul's right tho, what's the problem you are trying to solve with this process?
11 years ago
Thanks Michael and Rob for your reply. I actually realized I could use Rob's solution after I posted this yesterday. I keep these values stored in some of my saved objects and so I just check against the last value I had stored and ignore it if it is the same. Michael, I actually thought about your solution first yesterday, but I was too bothered by the fact that the spinner generated inconsistent results to want to develop it into a solution. It took me enough time just to chase down why my results were not what I expected. Of course, seeing it in code looks fairly straight-forward and wouldn't have been that hard to do.

Thanks to both of you for your input. Still not sure why I'm sometimes getting two events, but I have a way around it now.

Chris
11 years ago
W is right, if you are trying to keep 2 arrays that both point to the same objects as their elements you can't do that with primitives. You would have to us the Double class to hold your values. Rounding them doesn't save you any space either, if that is your purpose of not having 2 arrays of double primitives. Each value still uses up 8 bytes I think for double. It doesn't matter if the value is huge or zero.
11 years ago
I have a series of JSpinners that I am using in a GUI. I also have an inline change listener for each of them to handle the input, check it for out-of-range and pass the new value along to my software. The problem is that every second or third click on the spinner's up and down arrows generates 2 calls to stateChanged(). This forces my code to run twice, and since it can be a time consuming process when it runs, I am essentially doubling my run time for this process. I thought I could be clever and just trap the second call that occurred less that 50ms from the first one. That worked great! .... Except I realized that the second call I trapped actually carries the new value and the first call getting through carried the old one.

So my question is this: Why am I having to jump through hoops to get data off my spinners? Why is it sometimes tossing an extra call before it sends the real one I am expecting?

Thanks for any help...
Chris
11 years ago
I'm also having problems with it. Trying to search for "JScrollBar" in Swing forum and get zero results. Just looking at the Swing threads, I can see one on the front page today. I think search is messed up...
14 years ago
Thanks guys. I'll probably start by trying to use the plain vanila CachedThreadPool and see if I have any bottlenecking anywhere. If I have problems, I'll look into using the PriorityBlockingQueue to order the tasks.

Thanks for your suggestions.
I'm just now digging into the threading stuff introduced in java 1.5 (Executors and such). Is there a way to tell an executor that a runnable you pass it is more or less important than another?

Up till now I have been using the setPriority() method on my threads as I create them to allow more important threads to execute quicker when they are run by holding back on running the less important ones.

Thanks for your input.
Have you looked around for any free charting APIs? Seems like I remember at least a couple. Google is your friend. One I specificly remember looking at was JFree.

After you pick one of those, your only issue is getting at the data. The DB access should be no problem since you have access to that. The Excel file read is the only potential issue and then its only an issue if you are trying to run the program on a nonWindows machine. If you are working exclusively on windows boxes, check out JDBC access to excel files. If you are running on a different OS, one solution might to actually keep an extra record in the DB that is the "Standard Baby" instead of an actual patient. Then Its just 2 DB calls instead of one for the chart. If that's not feasible for some reason, you could always export the excel data to a delimited text file and read it in that way.

Hope this gets you going.
14 years ago
Can someone please tell me what exactly I can do with the graphics object created by the graphicsObj1.create(x,y,width,height). If I understand correctly, a graphics object cannot be directly placed or drawn into another graphics object or a BufferedImage. If thats the case, what good is returning a graphics object at all since I can't use the new sub section graphics object anywhere.

Perhaps someone can enlighten me on how to use the graphics object it returns. I understand the difference between a graphics object and an Image, I just don't understand what I can do with a parentless graphics object. I don't see any way to take its information and use it anywhere.

Thanks for any insight you guys can offer.
14 years ago
James:
here is a sample of a batch file (ignore newlines among the resources declaration, they are there for viewing purposes only)

The batch file lives in the same directory that contains the JRE folder.

I don't know if you could use the batch file to detect an available JRE. As far as I'm concerned, by the time I'm running the batch file, I'm assuming that my bundled JRE is already in in place. batch file creation isn't my specialty, so maybe someone else could tell you how to do it. As to your last question about how to know if a JVM is present on a client machine, I'm sure there is a simple way to detect it, but for my coding(apps only so far) I don't care. I drop mine in place and I know it's there. End of story.

I have used 3 different install maker applications. The first one was InstallShield Express. It was ok, but cumbersum at the time. I'm sure it is better now, but it's expensive to buy or upgrade. I then found a free version of InstallAnywhere 5.5 that has served our purposes nicely for the past couple years. To my knowledge, they no longer provide a free version of their software however. I keep backups of that software tucked away incase I ever need to reinstall it. I have been playing with a couple of others recently. One is called Install Creator and they have a free version you can play with if you want. A very simple one is from GatherBird (google it, you'll find it) but it didn't do enough.

Hope this gets you going.
_________________________

Ken:
No I grab the entire JRE directory which includes all the necessary libraries and binaries(java,javaw) to run for the JVM I have been coding to. I have only been distributing to clients in Windows environments, so as long as my upgrade code is done with the same JVM that I sent to a client originally, there are no compatibility issues. I do hand place code onto a linux embedded system that lives in our hardware, but once I have a single drive setup right, I just clone the disk for each new piece of hardware ordered. If I had to distribute on different platforms, it could still be done just the way I describe, only I would have to get the proper JRE flavor for the platform in question, just as you said. As far as installing it, if you can make an installer or tarball, or any form copying a directory structure and dropping it in place, then my method should work fine as long as your batch file was setup correctly for that platform(my linux batch is different from my windows batch).

Chris
[ January 20, 2006: Message edited by: Chris Shepherd ]
15 years ago
James: No you don't have to bundle everything that comes with the SDK. When it installs, it also includes a folder inside it called JRE. This is the same JRE you would get if you just installed the JRE on a client's machine. That folder, tho, is the one you want to copy out(copy, not move) and into your distribution folder.

Yes it is a fair size, but consider this. It would take up just as much space if it was actually installed on their machine somewhere else. Also, your 500KB program is only compiled java code and doesn't include any runtime functionality in and of itself. So the first time installation for a client has to be done by CD or downloaded from the internet, it most likely can't be mailed. The next update you put out with all those tasty improvements and bug fixes can be emailed as a small patch installer and contain only your changed jar files.

It does depend on your application and where you want the installation burden to lie. Does it fall to your users to go to the java website and download the JRE and install it before they install your program? Do you want to bear the burden of doing all the version checking on a client's machine prior to installation and then deal with bundling the JRE installer in a manageable way with your code(which will still be a big instalation file) so it all installs correctly? Or do you want the relatively clean way of sending a compartmentalized program all bundled up by itself that won't bother any other programs and places no burden on anyone except for the one small batch file that you must create to call your program with your bundled JRE. I can even provide you a sample if you need a template to work off of. Once you have the batch file made tho, there's no burden anywhere except on you to create a simple installation with the installation creator of your choice and on your user at the single point of installation where they follow your simple instructions.

Hope this helps,
Chris
15 years ago
Ken:

I deploy everything in the JRE directory plus my jar file and any other third party jar files needed for the app. I usually keep the jar files that are external to the JVM in a separate resources directory. It's probably possible to do the checks for compatibility and subsequently install the appropriate JRE, but why go through all that effort for a single standalone app? The file space needed to include the JRE(J2SE) directory is ~42MB. Thats peanuts on machines today, and even on most thumbdrives that wouldn't crimp your style too bad. My total deployment in place without the database(starts empty) is probably in the neighborhood of ~50MB by the time you include doc files and such.

Another advantage of keeping it compartmentalized is that if you need to upgrade the JRE because of new code you are passing out that needs it, you simply tell the customer he has to uninstall your old software and reinstall the new version. This doesn't affect anything else they have installed (java itself or programs that may depend on an installed version). Now doing the uninstall depends on you having used a bundled installer that registers itself for uninstalling, but I think thats fairly standard in installation makers.

If you thought you were going to be distributing more than one app, you could always reuse the same JRE for multiple programs. Just have it in a standard place in relation to all your apps. it could be one directory up from the app directorys. For example, you could make a master program directory for your company in the Program Files directory and then place your other directories like this:

c:/program files/<your company>/JRE
c:/program files/<your company>/app1
c:/program files/<your company>/app2

Then in your batch files you use to call the apps to open, you simply reference "../JRE/bin/java app1 ..blahblahblah.."

Ah well this is way too long, but hopefully it will help you get started.

Chris
15 years ago
Thanks for the suggestions Edwin. I took your advice and made sure I had everything serializable down the line, and it was all correct. I appreciate your thoughts.

I did find the problem tho. After I double checked all the classes for Serializable again,I wrote in some test code to serialize out just the problem object. I was able to pinpoint 4 problems in my readObject() method that were all related. This was my initial code. vectChngAmp is a float and vectChngTime is a long.

Evidently in fields.get(), java doesn't adapt the 0 to whatever data type is expected like it does in standard assignments and such. Here is what actually worked

Seems kind of odd to me that it doesn't work like the normal assignment does since that 0 value is meant to be assigned to the variable if the field doesn't exist.

Ah well, another lesson learned. Hope this helps somebody later on.

Chris
[ January 18, 2006: Message edited by: Chris Shepherd ]
15 years ago
I have been installing java apps for years on customer's computers. On my machine, I create a directory which includes my jarfile and support jar files that aren't part of the JRE. I also include the entire JRE directory structure. Once all the resources and the JRE are included, I write a batchfile to call my jar with the localized JRE and throw it in there too.

Then I get an installation creator and bundle the whole thing up and ship it to the customer. He gets shortcuts to the batchfile placed in his start menu and/or desktop.

The major advantages of this over just using an executable jar file is that the user doesn't have to have java installed and even if they do, it doesn't matter if their version isn't the right one. You package the correct version for your app along with it and it's done. As a side bonus, many times the app is mobile as long as you keep it in the same directory structure (ie, run it from your hard drive or a thumb drive, or a CD,etc) as long as they can find the batch file and its writen to be path neutral, they can run the program.

We also do this on our hardware running linux as well. We don't use an installer, but as long as you can get your directory structure in place in a home directory it will run. Now the batch file has to be different because of the differences in how batch files are processed, and the JRE is different, but once you have the correct directory structure, batch file, and JRE, you can place that structure anywhere you have permission.

Hope this helps,
Chris
[ January 17, 2006: Message edited by: Chris Shepherd ]
15 years ago