|
stubblyhead posted:Secondly, is it possible to make the class file executable on its own, similar to how you can write a perl script, set the execute flag and add #!/usr/bin/perl at the top? That depends what you are trying to do. If you want to create an executable file that you can distribute to other people, then follow Sebbe's advice. On the other hand, if you want to make it easy to execute arbitrary .jar files on your machine only, then set up binfmt_misc (this assumes it's already compiled into your kernel, which it probably is): http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/java.txt;hb=HEAD
|
# ? Jun 1, 2010 22:13 |
|
|
# ? Jun 12, 2024 02:59 |
|
Is there a solution for the issue where IE users that download .jar's get .zips?
|
# ? Jun 1, 2010 22:22 |
|
Shavnir posted:Is there a solution for the issue where IE users that download .jar's get .zips? sometimes you can coax IE with the "Content-Disposition" response header
|
# ? Jun 1, 2010 22:37 |
|
covener posted:sometimes you can coax IE with the "Content-Disposition" response header I've just been directly linking to the file so I donno where I'd put it in the response header.
|
# ? Jun 2, 2010 00:17 |
|
Shavnir posted:I've just been directly linking to the file so I donno where I'd put it in the response header. In some web containers static file servlet? Maybe a servlet filter if it doesn't expose any other way to add headers.
|
# ? Jun 2, 2010 03:32 |
|
covener posted:In some web containers static file servlet? Maybe a servlet filter if it doesn't expose any other way to add headers. No like from my webserver. Being hosted as a normal file through HTTP.
|
# ? Jun 2, 2010 03:36 |
|
Shavnir posted:No like from my webserver. Being hosted as a normal file through HTTP. assuming Apache HTTP Server -- modify your webserver configuration, via the real config or .htaccess, to add the "Header" directive in the context (<Location, <Files, etc) http://httpd.apache.org/docs/2.2/mod/mod_headers.html http://httpd.apache.org/docs/2.1/sections.html
|
# ? Jun 2, 2010 03:46 |
|
Sebbe posted:You are actually not telling Java to open HelloWorld.class, but rather telling Java to execute the main method on the class HelloWorld, which just so happens to be located in the directory you're in (which also by happenstance is the default class path.) If you don't need to put anything else in the manifest, then you can also use the -e option to set an entry point, like so: code:
|
# ? Jun 2, 2010 19:55 |
|
Sebbe posted:You are actually not telling Java to open HelloWorld.class, but rather telling Java to execute the main method on the class HelloWorld, which just so happens to be located in the directory you're in (which also by happenstance is the default class path.) So what happens if you have multiple classes with the same name within the classpath? How does java decide which one to execute? Or does it return an error?
|
# ? Jun 2, 2010 20:53 |
|
This is trivial, just try it yourself! vvv Edit: I was actually expecting it to complain about something. When I accidentally include servlet.jar twice in a webapp project, things start melting. epswing fucked around with this message at 22:20 on Jun 2, 2010 |
# ? Jun 2, 2010 21:12 |
|
epswing posted:This is trivial, just try it yourself! Point taken. I went ahead and did this, and java did successfully run one of the two classes. How does it decide which to run? Can I explicitly specify one over the other?
|
# ? Jun 2, 2010 21:44 |
|
fletcher posted:This is pretty hard to read. No need to have a comment for every closing curly brace. Pretty much any IDE will have brace matching for you, so you simply put the cursor next to any brace and it will highlight the other one. It also looks like you are trying to do some weird string comparisons when you are working with numbers. Something like this may be easier to read and debug: It's been a personal preference of mine to keep track of what part I was closing off. Still, I'd like to get better at making the code easier to read, so thanks for the input. Also, I think I wanted to eliminate the parsing step, but I do see how that still does the same thing I want and make it easier to read. I am in posted:I'll give a hint about the culprit. If you redo the code above to use this brace style I've tried that style of braces and I personally don't like it. I like seeing my braces line up. Internet Janitor posted:korofrog: is there a reason you're using compareTo("") rather than equals("")? No particular reason, just saw a demo program in this book that used it and I probably don't know any better. =) On to another problem..../sigh code:
1)DecimalFormat.applyPattern(String, boolean)line: not available 2)DecimalFormat<init>(String)line: not available amountList is an ArrayList object. If I don't try to apply the number format and just use (amountList.get(i)) I can get it to output, but not quite sure why I'm getting a source not found on the IDE. I've tried a couple other things like getting rid of the .toString(), adding Double.valueOf. Sorry for the noobish questions, but I have to learn somehow... EDIT: nevermind. I got it. Apparently, I can not do "###.#0" as that is not an acceptable pattern. I just switched all the #'s to 0's. D'oh! I really should not be trying to code simple things at 3am. korofrog fucked around with this message at 08:05 on Jun 4, 2010 |
# ? Jun 4, 2010 07:54 |
|
You could also use a plain String.format("%3.2f", amountList.get(i)); to convert a double or float to a string with 3 digits before the decimal point, and 2 after.
|
# ? Jun 4, 2010 08:09 |
|
korofrog posted:I've tried that style of braces and I personally don't like it. I like seeing my braces line up. My comment wasn't really about whether one brace style is better than another, rather it was the simplest step that would likely help you see the problem yourself.
|
# ? Jun 4, 2010 09:16 |
|
korofrog posted:EDIT: nevermind. I got it. Apparently, I can not do "###.#0" as that is not an acceptable pattern. I just switched all the #'s to 0's. D'oh! I really should not be trying to code simple things at 3am. While I'm sure that was a problem, I don't think it was the problem. In your original code, you're taking a Number (probably Double) out of the ArrayList, then calling .toString() on it, then trying to format that string. The compiler is telling you the .format() method takes a double, not a string.
|
# ? Jun 4, 2010 17:05 |
|
I just started working on a Tomcat application and it's been a while since I've done anything with Tomcat. I'm having a heck of a time solving the "where do we store user's preferences" problem. Basically, the application let's the system administrator configure, through the application interface, a location on the file system to store user files, among other things. All the serious configuration data would be stored here as well, but this means we need a known fixed writable location where we can store the path to this storage area. Obviously everything inside the web application's directory is writable, but the problem is that if we release an update and the user drops the new WAR file in for auto-deployment, the settings we've stored there get clobbered along with everything else. Another option is to store this in a dot-file relative to user.home, but my worry is that if Tomcat is running as a daemon then this might not be a good place. Is that always guaranteed to be a write-permitted location? So where the hell can I store a single string value in a place that is both writable from inside the web application, always known at time 0, and isn't going to be clobbered by auto-deployment? Flobbster fucked around with this message at 18:51 on Jun 4, 2010 |
# ? Jun 4, 2010 18:48 |
|
You *could use jndi to specify that poo poo. You won't clobber it with deploys and each tomcat instance could have its own configuration (development/testing/production etc). *I guess I should say could and not should here, since I don't know how enterprisey you wanna get. trex eaterofcadrs fucked around with this message at 20:25 on Jun 4, 2010 |
# ? Jun 4, 2010 20:20 |
|
TRex EaterofCars posted:You should use jndi to specify that poo poo. You won't clobber it with deploys and each tomcat instance could have its own configuration (development/testing/production etc). I tried that, but when I try to update the property from the control panel I've written in my app, I get an exception saying that the context is read-only. In my WEB-INF/web.xml file I have this: code:
code:
|
# ? Jun 4, 2010 20:27 |
|
Well, I was thinking more along the lines of having the sysadmins put the config file location into the jndi string, so that way they have to be aware of the location's permission restrictions. Then that config file can be altered by your app. Tomcat has a read-only jndi implementation, so unless you drop in another jndi provider (which I guess is not recommended) you won't be able to set anything in the directory "in-app".
|
# ? Jun 4, 2010 20:57 |
|
Outlaw Programmer posted:While I'm sure that was a problem, I don't think it was the problem. In your original code, you're taking a Number (probably Double) out of the ArrayList, then calling .toString() on it, then trying to format that string. The compiler is telling you the .format() method takes a double, not a string. Yes, I got rid of the toString() method. Like I said, I was up late trying to code something simple and missed the original problem of the number format pattern. In my head, I knew I wanted a precision of 2 with trailing zeroes so I thought using ###.#0 would work because I didn't want a leading 0. Turns out my thinking was flawed on the leading 0's and then I compounded the error by thinking I needed to use toString() on the arraylist. After I saw it I promptly smacked myself on the head. I am in posted:My comment wasn't really about whether one brace style is better than another, rather it was the simplest step that would likely help you see the problem yourself. I know. Brace position is up to personal tastes as far as I'm concerned, as long as the code block is enclosed, it shouldn't matter where it goes. It took me a little bit and I eventually just redid the if statement conditions and saw the extra parentheses in my second block. I'll go back and redo the first if condition to be .equals instead of .compareTo. Thanks Internet Janitor, that does make more sense. Also, to everyone else, thanks for your input. I'll probably have more questions soon enough.
|
# ? Jun 5, 2010 04:00 |
|
korofrog posted:I know. Brace position is up to personal tastes as far as I'm concerned, as long as the code block is enclosed, it shouldn't matter where it goes. It took me a little bit and I eventually just redid the if statement conditions and saw the extra parentheses in my second block. I'll go back and redo the first if condition to be .equals instead of .compareTo. Thanks Internet Janitor, that does make more sense.
|
# ? Jun 5, 2010 13:22 |
|
RichardA posted:You do realize that the error is not the extra parentheses? Ahh....yes. I had retyped the whole section of code without the extra parentheses on that second if statement and completely missed the fact I had a semi-colon there. It's just as well though, I switched out the compareTo()'s I had to isEmpty() instead and it still works and makes more sense. My newest problem is trying to get a buton to set the title of a frame. code:
|
# ? Jun 6, 2010 05:47 |
|
korofrog posted:That's what I have right now where changeCompanyName is a button and f is the JFrame. It compiles fine but when I run it I get nullpointerexception with EventDispatchThread.run() line: not available. Any ideas on how I can fix this? The issue is that when you assign the ActionListener what you're really doing is defining a new inner class. Think scoping and I bet you'll figure out the solution
|
# ? Jun 6, 2010 09:55 |
|
Shavnir posted:The issue is that when you assign the ActionListener what you're really doing is defining a new inner class. Think scoping and I bet you'll figure out the solution Thanks! That helped. I had declared f as a class variable but in the constructor I had put JFrame f = new JFrame(). So after removing the first JFrame, it worked fine. Also, Internet Janitor, that KeyListener on the length conversion part worked great! I had a couple issues with it at first but then realized I didn't change some variables after doing a cut & paste for the other measurements.
|
# ? Jun 6, 2010 19:14 |
|
Any Eclipse RCP experts in here? At work, we're trying to migrate one of our applications to the Eclipse RCP framework. For the most part, it has gone well. But we're hitting some sticking points for what we want to do. 1) There is a large part of our system that, naturally, has nothing to do with the presentation side of things. However, we want to allow plugins to listen in on some of this stuff. Now, normally this would be easy: whatever class can just add a listener to our stuff. But, how is this accomplished in a plugin? How can a plugin get a reference to some system in the main application so that it can add a listener? Is the assumption that such a system would have a static access point? 2) Workbenches, perspectives, pages, views, editors, etc. Fun stuff, and seems to offer a lot of possibilities. We want to accomplish something specific with this that is, at the moment, looking like a brick wall of impossibility. Let's say we have the main application, which consists of a view on the left side, and an empty area on the right (a placeholder). Now, in the placeholder area, we'd like new "windows" (not necessarily floating - they could be tabbed pages, as in when that area is an editor area). But, these windows need to have views inside of them, and this is where our lack of experience in Eclipse RCP shines. Have no clue on how to do that. A window within our workbench that can have its own views - views that can only be arranged, docked, etc, within that particular window. Preferably through its own perspective. So: main window has a view and a placeholder area. Place holder area can have multiple windows, each window having its own perspective of editors and views. Possible? 3) Is there any really good place of information? We have some older books, and the java doc pages, and snippets that they have. But, for the most part, it feels like information about Eclipse RCP is just all over the place, and not very well organized with good examples.
|
# ? Jun 10, 2010 02:14 |
|
Im using reflection for a Service toString. As an example, AccountService has a field UserService, which is an interface implemented by UserServiceImpl and its parent is AbstractServiceImpl. Assuming I already have the Field object for the UserService, how can I determine if it is an implementation of AbstractService? For example if I print out field.getType, I see the interface UserService. But if I try to do AbstractServiceImpl.class.isAssignableFrom(field.getType()), it always returns false. Sorry for the convoluted question but it gets down to what condition can I use so that any Field that extends AbstractServiceImpl returns true?
|
# ? Jun 10, 2010 04:57 |
|
Luminous posted:Any Eclipse RCP experts in here? I'm no expert but I've had my trial by fire on a million line eclipse plugin set so maybe I can give you assistance with #1. The plugin.xml defines dependencies and exports. So let's say you have two classes, one class called Worker in plugin com.example.workers, and another class called Listener in plugin com.example.listeners. You want the Worker to perform some work and the Listener to respond to the work. What you need to do is modify the com.example.workers/plugin.xml to export the Worker class. Then in the com.example.listeners/plugin.xml you need to assign the com.example.workers plugin as a dependency. The wizards are pretty decent for getting that done, although their intellisense is poo poo. I would manually type in the class/package info. If you do it right you should have no trouble using intellisense across exported/dependent plugins WITHOUT importing them the "normal" Eclipse way. This works in Eclipse 3.5, but I know they've just started using OSGi so I don't know if these instructions will work on Eclipse < 3.5.
|
# ? Jun 10, 2010 14:09 |
|
So, is that saying that if we want a plugin to listen to something external, then that external thing must also be a plugin (or, otherwise developed in the rcp way of things, whatever that may be)? For instance, let's say we have SomePackage.SomeClass in its own project. This SomeClass could be used as is in other programs simply by instantiating a new one code:
code:
I should have prefaced my last post with a "we are just beginning to learn Eclipse RCP and know nearly nothing" so, apologies for the near brain-deadedess of the questions. edit: For my first question, it looks like Extension Points is what we were looking for. Will have to put something on that to test it out. Hopefully resulting in me not having to follow up question #1, ha. Luminous fucked around with this message at 15:23 on Jun 10, 2010 |
# ? Jun 10, 2010 14:54 |
|
Luminous posted:So, is that saying that if we want a plugin to listen to something external, then that external thing must also be a plugin (or, otherwise developed in the rcp way of things, whatever that may be)? But yes you will want to put EVERYTHING your plugins touch into other plugins.
|
# ? Jun 10, 2010 15:27 |
|
Yeah, this seems to be working out well. Was just a step to realize that making something into a plugin doesn't mean it can no longer be used externally. Now that we're adding extensions and extension points, this is making a lot more sense. I am still searching for a way to nest views and editors, as well as nesting a page in a page. The lack of information is leading me to believe this is impossible, which would be quite a shame as that changes our workflow concepts for the application But if you, or anybody, know of a way (preferably simple) to get views into other views, then I am all ears. edit: Or maybe I just want a new workbench window, which can have its own perspective. I just don't know. Luminous fucked around with this message at 20:05 on Jun 10, 2010 |
# ? Jun 10, 2010 19:53 |
|
Luminous posted:Yeah, this seems to be working out well. Was just a step to realize that making something into a plugin doesn't mean it can no longer be used externally. Now that we're adding extensions and extension points, this is making a lot more sense. I'm not a "view guy", really. I know enough to be dangerous but I don't know the limitations of Eclipse's perspectives and views. I think you need to get the right terminology down and you'll probably find what you need.
|
# ? Jun 10, 2010 20:28 |
|
TRex EaterofCars posted:I'm not a "view guy", really. I know enough to be dangerous but I don't know the limitations of Eclipse's perspectives and views. I think you need to get the right terminology down and you'll probably find what you need. Yeah, terminology is a bitch. I do have another question regarding my first question, though: we have hit a little snag, and are hoping it is just our implementation (based off of the example provided here http://www.vogella.de/articles/EclipseExtensionPoint/article.html). In that example, the plugin that handles the extensions loops through the extensions that implement the extension point. But, when it loops through, it is actually creating new instances. This means, for instance, trying to add a listener results in a listener being added, but for an instance of the extension that we aren't actually using. Hur. The createExecutableExtension method seems to be the culprit for this, but we do not see a getExecutableExtension (for instance) that will get already existing ones. Maybe that's not even possible, as is. So basically: Plugin 1 defines an extension point and creates implementation code to loop through all implementing extensions and do something with them through the appropriate extension interface. Plugin 2 defines some class that implements the appropriate extension interface. Plugin 1 calls the appropriate extension interface, but on a "local" instance instead of the instance explicitly created in Plugin 2. What? Luminous fucked around with this message at 21:31 on Jun 10, 2010 |
# ? Jun 10, 2010 21:27 |
|
Ugh, Eclipse RCP is making me feel like a drooling retard. Why can I not find a simple example of how to share data across plugins? I already have some classes that represent data and actions on that data, and want to create a plugin that can either (or both) display that data or trigger actions on that data. I would have assumed this is a fairly common thing, but every example is so basic that you can't go anywhere from there. The only thing I can assume is that for such behavior, plugins expect static access points/factories. I've no real problem with this, but I simply want a yay or nay on if this is standard practice or if there is a different way that plugins accomplish data sharing and interaction. Extension points are nice, but, they don't seem to provide what we're looking for and I am trying to figure out if I just need to shift my thinking and expectations even farther in order to get a grip on how Eclipse RCP wants things done. This would be helped immensely by a simple application that has views in plugins that interact with or display data from some other plugin. The simplest example I've found that works is RSSOwl, and, that is far from simple.
|
# ? Jun 11, 2010 16:09 |
|
Luminous posted:I already have some classes that represent data and actions on that data Call the plugin that contains these "Plugin-A". quote:and want to create a plugin that can either (or both) display that data or trigger actions on that data. And call this "Plugin-B". Plugin-B must depend on Plugin-A. You have a couple options -- static classes or factories that are initialized when Plugin-A loads (therefore they'll always be ready by the time Plugin-B loads), or add instance methods to the activator/plugin class for Plugin-A that give you access to the data so that somewhere in Plugin-B you can say Plugin_A.getDefault().getMyDataModel().... Now, if you want Plugin-B to be able to respond to changes in Plugin-A's data that it didn't initiate, you'll need to make Plugin-A expose some kind of listener interface that Plugin-B can hook into when it loads. You can either do that hooking entirely in code, or this can be where extension points come in, because then you just add the listeners as extensions in the plugin.xml.
|
# ? Jun 11, 2010 16:39 |
|
I need to create a thread that waits until something happens and then does some stuff. How do I go about that? I assume this is a big no-no.code:
|
# ? Jun 11, 2010 22:29 |
|
IMlemon posted:I need to create a thread that waits until something happens and then does some stuff. How do I go about that? I assume this is a big no-no. Use Object.wait() and Object.notify().
|
# ? Jun 11, 2010 23:04 |
|
Since I'm on summer vacation (lots of free time!) I decided to do something that might be productive and help me in the future (I just passed the first year of my gymnasium and I'm thinking of studying something IT related in whatever university) - learning Java. This is my first experience with any programming language. So, following the advice in the What next? I guess I'll do the Debugger and Workbench tutorials from the same page, but what after that?
|
# ? Jun 13, 2010 19:30 |
|
Angryhead posted:I guess I'll do the Debugger and Workbench tutorials from the same page, but what after that? Think of a project: a problem to solve, something that helps you (or someone else) complete a computer-related task, a small game, etc. Make it really small, don't be too ambitious, it's better to complete a small project than to abandon a medium/large project. Then actually do it.
|
# ? Jun 13, 2010 20:33 |
|
Angryhead posted:What next? Check out codingbat.com
|
# ? Jun 14, 2010 07:00 |
|
|
# ? Jun 12, 2024 02:59 |
|
If I'm making a generic class <T extends BaseObject, V> how can I enforce that V is a long? If I say <V extends Long> I get an ugly warning about not being able to extend final classes, even though it seems to accomplish what I want. Is there any other way?
|
# ? Jun 16, 2010 17:45 |