|
Doctor w-rw-rw- posted:Well, seems reasonable to me, then. There are lots of ways to customize IntelliJ -- check out Live Templates and the Key mappings -- you can change just about everything. If there's anything in particular, we can try to help out. Also, you can have a lot of fun tweaking GC settings if responsiveness is part of the issue. I've found parallel + concurrent mark/sweep + incremental to be the most user-friendly and G1 the least. As always, ymmv. narbsy fucked around with this message at 04:55 on May 10, 2012 |
# ? May 10, 2012 04:52 |
|
|
# ? May 20, 2024 20:03 |
|
So I have an exam tomorrow and there's one pesky little question I can't figure out -- it might just be a typo in the practice exam. So if an abstract class has an abstract method, say public abstract int total(); the subclass has a method total, but it's written as public double total(){ There's a calculation with a double in the subclass method, so when I did the practice test I wrote public int total(){ etc } and just cast it back to an int when returning it. So the question is, is it cool to override the type like that, or is it just an oversight in the answer key?
|
# ? May 10, 2012 07:05 |
|
Turkeybone posted:So the question is, is it cool to override the type like that, or is it just an oversight in the answer key? There's a case where it's okay and there's a case where it isn't. Put simply, this is when it's not okay, but if you'd like to know more, here's an explanation: Java allows something called covariant return types on methods. The idea is that if you've got a class or interface defining a method public InputStream getSomeInputStream() then any implementation needs to return an InputStream. The implementation can't return something completely different like an OutputStream. Let's say you make an implementation which returns a FileInputStream. That's valid since it's an InputStream and that's what the method signature says you'll return. But what if you want to let people using your class that it's always going to return a FileInputStream? Java allows your implementation to declare the method as public FileInputStream getSomeInputStream() and it'll still work. It's generally considered bad form since it allows people to write code that will work with your implementation by expecting a FileInputStream but won't work with anybody else's. In your case it's a int and a double. Neither type inherits from the other type or from anything else because they're not objects, they're primitives and primitives don't have any inheritance behavior. Even if the abstract parent class had the method defined as public abstract Object total() it's still not allowed because of the whole not being objects bit.
|
# ? May 10, 2012 08:38 |
|
Hmm, thanks for the explanation. They teach us inheritance/real type/apparent type with silly things like Animal and Dog, Cat, etc. So, to put it in cs100 terms for me, in this case I could do public abstract Animal getAge() and then later write extend Animal with something like public Cat getAge() ? It's probably just an oversight in the exam, then. The next level class is more about abstracts and interfaces, etc, so I don't think they'd throw this at us at this juncture. Thanks for the help
|
# ? May 10, 2012 08:57 |
|
It'd be weird for a method that's named getAge() return an animal object rather than some number representing age. If you'd replace getAge() with something like getCritter() then yes, you could do that. With the caveat that it's usually not nice form, as 1337JiveTurkey explained. The implementation might be something like public Animal getCritter() { Cat critter = new Cat(); return critter } where it may only use a concrete Cat object internally, but doesn't make the specific claim of returning a Cat; just some kind of Animal. I'd guess it's not a typo, just something they would expect you to be mindful of when implementing methods.. anyhow a modern IDE would pick up and alert you of the incompatible return type right away. pigdog fucked around with this message at 09:50 on May 10, 2012 |
# ? May 10, 2012 09:37 |
|
pigdog posted:It'd be weird for a method that's named getAge() return an animal object rather than some number representing age. If you'd replace getAge() with something like getCritter() then yes, you could do that. With the caveat that it's usually not nice form, as 1337JiveTurkey explained. The implementation might be something like public Animal getCritter() { Cat critter = new Cat(); return critter } where it may only use a concrete Cat object internally, but doesn't make the specific claim of returning a Cat; just some kind of Animal. haha yeah sorry, I've been studying too long and was just grasping for an example. the answer key is doing the illegal thing here, by using double instead of int. And it's a written exam so in this case, the IDE won't be of help (we are babbys who use Dr. Java). But I realize this is a very specific and convoluted case, so I appreciate all of your insights, and I won't belabor this any further!
|
# ? May 10, 2012 10:11 |
|
Turkeybone posted:haha yeah sorry, I've been studying too long and was just grasping for an example. the answer key is doing the illegal thing here, by using double instead of int. And it's a written exam so in this case, the IDE won't be of help (we are babbys who use Dr. Java). Agh gently caress Dr. Java. Had to use it last semester, probably will be using it again next semester for an OOP class with Java. I only used it when I had to run our final programs and print the output in the format my prof wanted. It's slow as hell and awful.
|
# ? May 11, 2012 20:33 |
|
I'm trying to make a JDialog with a JColorChooser and two buttons, but for some reason the panel with the colorchooser and buttons is way too high. Here's my code:code:
|
# ? May 16, 2012 19:09 |
|
Worth noting that the forums now have syntax highlighting for new languages including Java. You just put "code=java" instead of "code" in the square brackets.Java code:
|
# ? May 21, 2012 05:38 |
|
Is there a Java library that would allow me to run a command line executable on a remote server? After searching around a bit I found a few solutions that involved running telnet or ssh through RumTime() but the remote server I'm working with has those locked down for security.
|
# ? May 25, 2012 20:29 |
|
origami posted:Is there a Java library that would allow me to run a command line executable on a remote server? After searching around a bit I found a few solutions that involved running telnet or ssh through RumTime() but the remote server I'm working with has those locked down for security. Need more explanation on what you are trying to do here and why?
|
# ? May 25, 2012 20:44 |
|
origami: Is there a particular reason you want to use Java for that? Is this supposed to be a tool that runs one specific command remotely or something more general-purpose? I think you need to elaborate upon what you're trying to accomplish, because this is soundling like an XY problem. edit: ^^^
|
# ? May 25, 2012 20:45 |
|
HFX posted:Need more explanation on what you are trying to do here and why? I have a python script I run on a few of my work servers that does some tedious tasks for me including importing oracle data, running sql scripts and configuring applications. I just run it through the command line (while on the server) with a few options; it's pretty simple. I would like to run this script remotely from my desktop machine or even just run programs from the command line like if I were logged onto the server. The reason I'm using Java for this is because I started futzing around with the GUI creator in NetBeans and I thought it would be nice to add the functionality to what I was already working on. I can already drop/create users and do other tasks on my remote servers using JDBC but unfortunately I cannot figure how to run other programs like I could if they were local to my desktop machine.
|
# ? May 25, 2012 21:07 |
|
There's the Jsch library, which does most things SSH. Apache Ant uses it in tasks that can execute commands or copy files securely. E: Ooops, I missed the bit about SSH being locked down. If SSH is not open then it's likely the server is not Linux or it's not meant to be remotely accessible. Max Facetime fucked around with this message at 21:21 on May 25, 2012 |
# ? May 25, 2012 21:08 |
|
How would (or do) you do this without Java? You mentioned that the servers have SSH locked down.
|
# ? May 25, 2012 21:12 |
|
Lysidas posted:How would (or do) you do this without Java? You mentioned that the servers have SSH locked down. I don't think I would be able to just using a command line. I am in posted:There's the Jsch library, which does most things SSH. Apache Ant uses it in tasks that can execute commands or copy files securely. Thanks although I think that would require a listening ssh process on my remote servers.
|
# ? May 25, 2012 21:16 |
|
That wasn't my question. How do you run this script now? You said that you run them on the servers, but you can't connect to them with SSH? Are you physically at the servers, or something like that?
|
# ? May 25, 2012 21:18 |
|
Lysidas posted:That wasn't my question. How do you run this script now? You said that you run them on the servers, but you can't connect to them with SSH? Are you physically at the servers, or something like that? Ah, logging in through RDP.
|
# ? May 25, 2012 21:21 |
|
origami posted:Ah, logging in through RDP. If you can log in through RDP there is no reason SSH can't be run on a non standard port just as safely (use a public key for authentication). While I know of nothing that meets exactly what you want to do, you can always make a rpc / rmi / your flavor of remote procedure calls here, that runs over ssl and authenticates both sides. It shouldn't take to long to write (couple of days tops). Edit: Google search reports this: http://properjavardp.sourceforge.net/
|
# ? May 25, 2012 21:25 |
|
Mentioning that they're Windows servers early on would have been useful, instead of mentioning SSH being locked down (which implies that it's installed but disabled, which implies some type of Unix) I recommend Sysinternals' PsExec. Making a local psexec call from a Java GUI shouldn't be too difficult.
|
# ? May 25, 2012 21:27 |
|
Lysidas posted:Mentioning that they're Windows servers early on would have been useful, instead of mentioning SSH being locked down (which implies that it's installed but disabled, which implies some type of Unix) Haha, my apologies. I'll checkout psexec and if I run into issues I'll follow-up on HFX's advice.
|
# ? May 25, 2012 21:30 |
|
Does IDEA (free edition) have all the features in eclipse (e.g. search and replace) and if not which are missing? I'm thinking of giving it a go, but I'd like to hear more about it if possible. Also can you do android coding on it? Fake edit: The website seems pretty ambiguous about this, which is why I'm asking.
|
# ? May 31, 2012 01:09 |
Private Speech posted:Does IDEA (free edition) have all the features in eclipse (e.g. search and replace) and if not which are missing? I'm thinking of giving it a go, but I'd like to hear more about it if possible. Yeah it has search & replace, tons of refactoring tools, debugging tools, etc. I can't think of anything I used in Eclipse that IDEA (free edition) doesn't have. fletcher fucked around with this message at 04:55 on May 31, 2012 |
|
# ? May 31, 2012 04:36 |
|
fletcher posted:Yeah it has search & replace, tons of refactoring tools, debugging tools, etc. I can't think of anything I used in Eclipse that IDEA (free edition) doesn't have.
|
# ? May 31, 2012 05:11 |
Doctor w-rw-rw- posted:Are you an Android dev? ADT is heavily tied to Eclipse and I'm skeptical that IDEA would have first-class Android support quite so extensive. It's a big deal to me, personally. Nope, I don't have any experience doing android dev in it.
|
|
# ? May 31, 2012 09:25 |
|
How do I adjust a date-time to a future time? Say I have this date-time object: May 31 2012 10:54AM UTC How do I adjust its time portion to something like 10AM but have it go forwards, so I end up with June 1 2012 10:00AM UTC instead of May 31 2012 10:00AM UTC? I'm really bad at calendar stuff so I have no idea what the hell. I'm using the ThreeTen alpha builds but I can presumably adapt a JodaTime solution/similar to work with it.
|
# ? May 31, 2012 18:58 |
|
Aleksei Vasiliev posted:How do I adjust a date-time to a future time? A quick hack, and potentially the best solution, would be to replace the time portion of the date with 10AM, compare it to the old one, and if it's earlier, add a day. See: http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTime.html withTime(...) and plusDays(1). Or withTimeAtStartOfDay() and plusHours(10) instead of withTime().
|
# ? May 31, 2012 20:05 |
|
Has anyone tried out JavaFX 2 & FXML? Is there any point in learning it? I use WPF/xaml/NET at work all day, but at school everything is Java. Going from building crazy layouts w/ two-way databinding in minutes to hand-coding swing is just killing me, and I figured FXML might be a bit more sane, but if it's just a total dead-end, I don't want to waste the time on it.
|
# ? Jun 8, 2012 02:16 |
|
I'd say that Java UI applications are a dead end to begin with.
|
# ? Jun 8, 2012 11:11 |
|
Is there even a decent JavaFX UI designer? The tutorials I tried with it were all written by hand. In other words, no, it's not going to be as good.
|
# ? Jun 8, 2012 18:58 |
|
MEAT TREAT posted:I'd say that Java UI applications are a dead end to begin with. Agreed, but if one *really* wants to do UI on Windows, then SWT is probably the toolkit to use (see http://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html for a small example). It'll look typically bland like most Java UIs. There's also 'clutter' and java bindings for it, neither of which I have ever used, but if you're going to want an application to look good, Java won't help you.
|
# ? Jun 8, 2012 19:10 |
|
carry on then posted:Is there even a decent JavaFX UI designer? The tutorials I tried with it were all written by hand. That doesn't bother me, when writing XAML I keep the 'designer' closed all the time anyway. In a way, that's the point of a markup language for UI layout. Doesn't Android use a markup language of some kind for UI? But I guess Java UI outside of Android seems pretty dead. Unfortunately I'm taking an Image Processing class (like filtering, color manipulation, fourier transforms, etc...) and it's all in Java. Not looking forward to writing a photoshop knockoff in swing...
|
# ? Jun 9, 2012 01:30 |
|
Nevermind, I am dumb.
|
# ? Jun 10, 2012 19:48 |
|
I have an application running continuously. As part of that application, once a day a start condition will be met (items are added to a queue by user). Once that happens, every 30 seconds or so I need to check for an end condition, then perform a task (deal with the queue). After the task is performed, I have no reason to want the timer to keep firing. Is there a better solution?Java code:
|
# ? Jun 28, 2012 16:57 |
|
For something like that I'd probably use Quartz: http://quartz-scheduler.org/
|
# ? Jun 28, 2012 22:13 |
|
trex eaterofcadrs posted:For something like that I'd probably use Quartz: I've used Quartz but I don't see how it would make things more elegant? It seems like I would just be using a SimpleTrigger to execute a Job instead of a Timer to execute a TimerTask.
|
# ? Jun 28, 2012 22:45 |
|
baquerd posted:I've used Quartz but I don't see how it would make things more elegant? It seems like I would just be using a SimpleTrigger to execute a Job instead of a Timer to execute a TimerTask. Mostly to externalize the configuration and have an de facto industry standard component for task scheduling. More software engineering than development elegance, I suppose.
|
# ? Jun 28, 2012 22:48 |
I need to split up an array into smaller arrays of a certain size, so I came up with this:code:
|
|
# ? Jun 28, 2012 23:04 |
|
Go here: http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/index.html and look up Lists: http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/collect/Lists.html there's a partition method. Use that. If you can't add another library to your code, then get it from git and put the guts of that method into yours.
|
# ? Jun 28, 2012 23:19 |
|
|
# ? May 20, 2024 20:03 |
Awesome, third party libraries are a-ok. I thought for sure Apache Commons would have something to do this, but I couldn't find anything in there. Thanks for the links, definitely gonna use this instead. Looks like there is a ton of other useful stuff in this library as well. At any rate, can somebody rip apart my method and tell me why it sucks?
|
|
# ? Jun 28, 2012 23:29 |