hooah posted:Could you go into a little more detail? Keep in mind I've never worked with java or Eclipse before. Here's the dialog I see when I choose fix project: I'd reckon it's either the "Add JARs" or "Add External JARs" button. Did you try either of those before your post? edit: here ya go https://www.youtube.com/watch?v=EeYGak5DeBg fletcher fucked around with this message at 03:42 on Dec 19, 2013 |
|
# ? Dec 19, 2013 03:38 |
|
|
# ? Jun 12, 2024 03:54 |
|
Alright, I got the import working (turns out I had to import "kareltherobot", not add any external stuff), but I can't figure out the right name to extend. I've tried Karel, KarelJRobot, and kareltherobot. Here's my project directory:
|
# ? Dec 19, 2013 14:35 |
|
hooah posted:Alright, I got the import working, but I can't figure out the right name to extend. I've tried Karel, KarelJRobot, and kareltherobot. Here's my project directory: You've got to import the package by it's package name and follow it by a .* or a specific class. For example: Java code:
Java code:
|
# ? Dec 19, 2013 14:40 |
|
Woodsy Owl posted:You've got to import the package by it's package name and follow it by a .* or a specific class. For example: Yeah, import kareltherobot.*; is what I did.
|
# ? Dec 19, 2013 14:50 |
|
hooah posted:Yeah, import kareltherobot.*; is what I did. What's the error that you're receiving?
|
# ? Dec 19, 2013 14:52 |
|
Woodsy Owl posted:What's the error that you're receiving? I have a line that says public class OurKarelProgram extends kareltherobot{. The problem is that I can't figure out what to put after extends that will satisfy Eclipse. Anything I put there gets underlined, and the mouse-over pop-up says "[whatever] cannot be resolved to a type". I've tried Karel, KarelJRobot, and kareltherobot.
|
# ? Dec 19, 2013 15:14 |
|
hooah posted:I have a line that says public class OurKarelProgram extends kareltherobot{. The problem is that I can't figure out what to put after extends that will satisfy Eclipse. Anything I put there gets underlined, and the mouse-over pop-up says "[whatever] cannot be resolved to a type". I've tried Karel, KarelJRobot, and kareltherobot. Oh okay. The keyword 'extends' makes your class an extension of the particular class. So, the 'extends' keyword needs to be followed by a class, not a package. What it means is that your class becomes an extension of the class; your class has the same methods and constructors as the extended class, and you can add your own methods to your class to 'extend' the method. Java code:
edit: Depending on what the task/assignment is, you might not even need to use the 'extends' keyword. Woodsy Owl fucked around with this message at 15:30 on Dec 19, 2013 |
# ? Dec 19, 2013 15:26 |
|
Woodsy Owl posted:Oh okay. The keyword 'extends' makes your class an extension of the particular class. So, the 'extends' keyword needs to be followed by a class, not a package. What it means is that your class becomes an extension of the class; your class has the same methods and constructors as the extended class, and you can add your own methods to your class to 'extend' the method. That helps conceptually, but not really specifically, since evidently the Karel distribution I grabbed isn't quite the same as the one used in the Stanford lectures, so I don't know which class I should be extending. Hmm. As an aside, do you need the this. in a method, or can you leave the data member naked as in C++?
|
# ? Dec 19, 2013 15:33 |
|
hooah posted:That helps conceptually, but not really specifically, since evidently the Karel distribution I grabbed isn't quite the same as the one used in the Stanford lectures, so I don't know which class I should be extending. Hmm. Here's a page I found on Karel for java http://programmingjava.net/2-basic-karel-program/ http://programmingjava.net/3-improve-karel-using-methods/ Looks like that's the same library you're using? Yeah, if the Stanford library is named differently than yours then the extends won't work. Unfortunately that means the rest of the API might be different too, so you may want to go back and try to find a better stanford karel library and get that working. Although... this page here references Stanford. Hmm. Maybe they are the same. You generally don't need to use "this." in a method, class field variables have full class scope. However, if you have a variable with a name like myVar, and then in a method you declare "int myVar = 10;" you're going to now have no way to refer to the class level variable myVar, since they're the same name. This is called shadowing, and the way you can get around it is by saying "this.myVar". The other case where you need this. is if you're passing yourself as a reference ( myMethod(this); ) or some other special cases. It isn't usually needed, no. Looks like this should work Java code:
Zaphod42 fucked around with this message at 17:00 on Dec 19, 2013 |
# ? Dec 19, 2013 16:56 |
|
Zaphod42 posted:Here's a page I found on Karel for java I'm not sure if it's the same library. The one I got was from Pace University; the link from that Java tutorial is dead. The first thing I tried doing while watching the lecture video was saying import standford.karel.*;, and Eclipse couldn't resolve the stanford import. I used the contact link on the Stanford site to ask if there's somewhere to download the Karel project or if they could make heads or tails of the error their Eclipse distro was giving me, but based on their automated response, I'm not hopeful.
|
# ? Dec 19, 2013 17:34 |
|
hooah posted:I'm not sure if it's the same library. The one I got was from Pace University; the link from that Java tutorial is dead. The first thing I tried doing while watching the lecture video was saying import standford.karel.*;, and Eclipse couldn't resolve the stanford import. I used the contact link on the Stanford site to ask if there's somewhere to download the Karel project or if they could make heads or tails of the error their Eclipse distro was giving me, but based on their automated response, I'm not hopeful. I'm confused. You said you were doing Stanford's intro to programming course. Stanford sent you to Pace? You can't use somebody else's library without some kinda documentation. If the links are dead then don't use that. What are you doing this for anyways? Trying to learn java? There's infinity tutorials out there, pick a new one that's better documented and better maintained. Trying to follow along with a different library probably won't work well, especially if you're new. You'll just keep getting bogged down and lost.
|
# ? Dec 19, 2013 18:00 |
|
rhag posted:What do you mean by cannot perform? Has that index table indexes created for the indexName and indexValue fields? Such as CREATE INDEX IDX1 on Index (indexName,indexValue) ? Is customerId a primary key on the other tables? Or has an index made for it? We are running a Teradata database. It is not meant to be an operational database, it will never be an operational database, and trying to make it perform like an operational database will never work. This was big corporation political fuckery that cannot be unfucked so it needs to be taken as a constant. (It is so bad that we are now storing our ENTIRE data model as a json object in one table, thus we have no indexes because we essentially have no data model). I can go on for days about how terrible this situation is but it will not help as this is the situation and no one will change it. So the problem is that we have a JSON blob as our entire database and no way to query it, thus the terrible index table was born. Even that has been tuned to poo poo by Teradata's experts and its not good enough. So whats are some alternative choices for an indexing application? We would really like something thats already built and open sourced - our best choice at the moment is Lucene because it can handle fuzzy searching on some of these index values like email and first name. Are there any other options that might work?
|
# ? Dec 19, 2013 19:09 |
|
FateFree posted:We are running a Teradata database. It is not meant to be an operational database, it will never be an operational database, and trying to make it perform like an operational database will never work. This was big corporation political fuckery that cannot be unfucked so it needs to be taken as a constant. (It is so bad that we are now storing our ENTIRE data model as a json object in one table, thus we have no indexes because we essentially have no data model). I can go on for days about how terrible this situation is but it will not help as this is the situation and no one will change it. Ouch, this is worse than I thought. Even a DBA cannot save you now (probably). What I would do (before bringing the experts, paying them a bazillion bucks to "fix it"), i would try a NoSQL document store database. MongoDB, cassandra may be good things to try, especially since you are already storing json documents in the database. Personally i have no experience with these though, but plenty of people over the internets do. Who knows, it may work. If nothing works, i would seriously consider going to Teradata and just make them fix it. I assume you have a contract with them, take advantage of it as much as you can.
|
# ? Dec 19, 2013 19:20 |
|
Zaphod42 posted:I'm confused. You said you were doing Stanford's intro to programming course. Stanford sent you to Pace? I'm doing Stanford's free online course, yes. They didn't provide any sort of Karel anything, so I went looking for something to grab, and found the Pace one. Since it looks like the Stanford course isn't going to work (at least not the first however many lectures until he moves on past Karel), what tutorials do you recommend? I'm looking to learn Java between semesters so I can go into my second semester with a little more of a varied background than just C++.
|
# ? Dec 19, 2013 20:19 |
|
hooah posted:I'm doing Stanford's free online course, yes. They didn't provide any sort of Karel anything, so I went looking for something to grab, and found the Pace one. If you've got a bit of a background in programming already (it sounds like you've done some C++) then I would suggest you work through the beginning of the official Oracle Java Tutorials. I would suggest you start at Lesson: Language Basics so you can see how Java syntax differs from C++.
|
# ? Dec 20, 2013 07:54 |
|
Woodsy Owl posted:If you've got a bit of a background in programming already (it sounds like you've done some C++) then I would suggest you work through the beginning of the official Oracle Java Tutorials. I would suggest you start at Lesson: Language Basics so you can see how Java syntax differs from C++. Thanks. I also grabbed the videos mentioned in the OP.
|
# ? Dec 20, 2013 13:34 |
|
hooah posted:Thanks. I also grabbed the videos mentioned in the OP. Packt have a sale until Jan 5th on all ebooks. https://www.packtpub.com/ebookbonanza Maybe one from there can help.
|
# ? Dec 20, 2013 14:20 |
|
Be very very careful with Packt, most of those books aren't worth $5.
|
# ? Dec 20, 2013 15:55 |
|
Posting Principle posted:Be very very careful with Packt, most of those books aren't worth $5. Oh, I didn't know that. I got https://www.packtpub.com/spring-security-3-1/book some time ago and it was fine. I can only advise then to check out reviews of a book before buying it.
|
# ? Dec 20, 2013 16:47 |
Hey I've got a couple of newbie questions. I'm not really good with all my vocabulary so hopefully these are understandable. 1. So it seems like java classes can implement multiple interfaces, but what about when dealing with "question mark notation"? For example, I can have a Class like : public class Dog implements Animal, Guard. Where a class, Dog, is implementing two interfaces Animal, and Guard, But I don't seem to be able to do something like this: ArrayList<? extends Animal, Guard> . What I'd really like to be able to do is something like: ArrayList<? extends Dog, implements Guard, Animal> (Then I could fill in the list with GermanShepard, PitBull (Sub Classes of Dog) types etc. Does that make sense? Is there any way to do it? 2. Can an object reclassify its self? Say I have a super class, Person, and two sub-classes Male, and Female. Would it be possible for Male to have a method mTF() that would change it to a female? So I could Instantiate John as a male, call the mTF function, and then John would then be a Female? Thanks
|
|
# ? Dec 20, 2013 21:13 |
|
greenchair posted:Hey I've got a couple of newbie questions. I'm not really good with all my vocabulary so hopefully these are understandable. By question mark notation, you're talking about Generics. quote:2. Can an object reclassify its self? Say I have a super class, Person, and two sub-classes Male, and Female. Would it be possible for Male to have a method mTF() that would change it to a female? So I could Instantiate John as a male, call the mTF function, and then John would then be a Female? No. In Java, a person is either male or female, and cannot transition at runtime. Such a concept does not exist, and all runtimes are cisgender oppressors. Edit: \/\/\/ listen to this guy instead Volmarias fucked around with this message at 21:57 on Dec 20, 2013 |
# ? Dec 20, 2013 21:41 |
|
greenchair posted:Hey I've got a couple of newbie questions. Java code:
Java doesn't support gender changes. Born a male, always a male. You can however create an identical clone of John who is a female. Java code:
|
# ? Dec 20, 2013 21:50 |
|
Or, you know, you can store the sex as a member of the Human (or Person or whatever) class and change it as often as you'd like. Don't abuse inheritance. Is a powerful tool, but one that can lead to a complete mess when used improperly. In this case, we can see clearly that a Person has a sexual identity (just like it has a name, address, etc.). The person is not male or female. Before subclassing always ask yourself: Is Foo Bar, or does Foo have Bar? The answer to that question pretty much can tell you if you should or shouldn't inherit Foo from Bar.
|
# ? Dec 20, 2013 22:29 |
|
^^^^ Listen to this man.greenchair posted:What I'd really like to be able to do is something like: I think you're making it way harder than it needs to be. How familiar with OOP, inheritance, and generics are you? Why not just create new interface SubDog extends Dog implements Guard, Animal, then all your objects extend SubDog. ArrayList<SubDog> Although logically Dog would implement Guard, Animal or... yeah probably reorganize your class hierarchy.
|
# ? Dec 20, 2013 22:37 |
Thanks that's really helpful! Are there any languages that would support the "mTF()" type thing? I was thinking that the reason It'd be useful is that the Male and Female subclasses would have different methods, or perhaps different implementations of an abstract superclass method.
|
|
# ? Dec 20, 2013 22:38 |
|
greenchair posted:Thanks that's really helpful! Are there any languages that would support the "mTF()" type thing? I was thinking that the reason It'd be useful is that the Male and Female subclasses would have different methods, or perhaps different implementations of an abstract superclass method. See Static vs Dynamic typing, such as Duck Typing. http://en.wikipedia.org/wiki/Type_system http://en.wikipedia.org/wiki/Duck_typing TL;DR: Yes.
|
# ? Dec 20, 2013 22:40 |
I'm pretty new to OOP so it's also very likely that I should just rethink my strategy too. ed. Thanks for those links I'll check them out! greenchair fucked around with this message at 22:43 on Dec 20, 2013 |
|
# ? Dec 20, 2013 22:40 |
|
The difficulty is in the fact that each type may have properties or methods which do not exist in the other. To use a better example, if both Circle and Triangle extend Shape, but Circle has center and radius, while Triangle has point1, point2, point3, how could you possibly do a circleToTriangle() without programmer insight? While duck typing systems let you stuff a triangle into a variable which before held a circle, true conversions like that aren't really possible in the language itself.
|
# ? Dec 20, 2013 22:44 |
|
I want to run a program using Process proc = Runtime.getRuntime().exec("program"); and then move the program's frame to a specific location on the screen. How can I do this?
|
# ? Dec 21, 2013 17:32 |
|
If you have no control over that program and can't make any assumptions about its behavior, you might be able to cobble together something via the AWT Robot: http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html If it was a program I'd written I might just add some command-line arguments for positioning the window.
|
# ? Dec 21, 2013 17:35 |
|
So I need to take a screenshot and then write an algorithm to find that window and move it with the awt robot? There isn't an easier way?
|
# ? Dec 21, 2013 17:38 |
|
I was kind of assuming that the window was starting out in a consistent position, which would allow you to simply use the Robot to blindly drag the window into the desired position, but I recognize that this approach may not always be feasible. Perhaps you could elaborate upon what you are trying to accomplish?
|
# ? Dec 21, 2013 17:44 |
|
Internet Janitor posted:If it was a program I'd written I might just add some command-line arguments for positioning the window. Here is the man for gnomine http://csurs7.csr.uky.edu/cgi-bin/man/man2html?gnomine+6 when I try to run 'gnomine -a X -b Y' It says 'Unknown option -a' ???
|
# ? Dec 21, 2013 17:45 |
|
Fedaykin posted:I am trying to write a bot that solves the gnomine minesweeper game that comes with ubuntu. Is that the man page for the actual version you have installed on your system?
|
# ? Dec 22, 2013 00:23 |
|
I am attempting to generate KML files using the JAK KML library. I have successfully done so however when this code was migrated from Tomcat -> IIS platform it stopped functioning. IIS is using java 1.6 while tomcat was on 1.7, but all the .jars for JAK are compiled with 1.6 I believe. The problem I am having is the file size for the .kml files are 0 when the code is finished executing. I am calling KML.marshal(new file('file.kml'). The kml.document does contain the placemarks I am attempting to write to the file. And it doesnt seem to be a permissions issue with the directory because I am able to write to it with .txt files or if I use a bufferedwriter. In the working environment kml.marshal() returns true in the non working it returns false.. DholmbladRU fucked around with this message at 22:47 on Dec 30, 2013 |
# ? Dec 30, 2013 21:47 |
|
Regarding Swing app development: what is the common practice for implementing behavior (ActionEvents and so on) for Swing components; in the JFrame's class, or in a parent class that instantiates one of the JFrames and adds necessary action listeners to it on instantiation? It's my very first Swing app so I'm not sure what the design standard is, but I'm partial to the second option because I'll be bringing together multiple classes (JFrames and helper classes) to implement the behavior of my application and I want to abstract the behavior away from the JFrames. Essentially I want the JFrame instantiation to handle building the window (adding components to itself), but the behavior methods of the components will be defined outside of the JFrame's class. I think this is efficient because I'm leaving the design part of the application inside the JFrames and then defining the behavior/usage part in my application class. Am I on the right track here? Or is there no real standard and it's really just subjective and relative to the task at hand and the programmer/designer? Is it totally a design decision? edit: Also, are there any LookAndFeels that I should be avoiding due to some community hatred? I quite like working with the Nimbus LAF, but I could see how some people could be irritated by it... Woodsy Owl fucked around with this message at 11:32 on Dec 31, 2013 |
# ? Dec 31, 2013 03:01 |
|
Woodsy Owl posted:Regarding Swing app development: what is the common practice for implementing behavior (ActionEvents and so on) for Swing components; in the JFrame's class, or in a parent class that instantiates one of the JFrames and adds necessary action listeners to it on instantiation? It's my very first Swing app so I'm not sure what the design standard is, but I'm partial to the second option because I'll be bringing together multiple classes (JFrames and helper classes) to implement the behavior of my application and I want to abstract the behavior away from the JFrames. Essentially I want the JFrame instantiation to handle building the window (adding components to itself), but the behavior methods of the components will be defined outside of the JFrame's class. I think this is efficient because I'm leaving the design part of the application inside the JFrames and then defining the behavior/usage part in my application class. Swing has been ... deprecated in the last few years in favour of the new and shiny javafx. There is no "standard" per se, but the design should follow the same principles as anywhere else: avoid tight coupling, components should do one thing and one thing only, delegate as much as possible, etc. What you can do:
Late edit. Regarding look and feels: most people prefer the applications they run look and feel consistent with the other ones on their desktop. I too get annoyed at the lovely app that the dev with too much time on their hands decided for no good reason to make it "pretty", essentially making it "stand out", often breaking the guidelines for that particular platform. Therefore, i recommend you use the system look and feel. Swing has a good windows xp replication, im not so sure on windows 7/8. So, your app will look a bit weird no matter what. But at least try to follow the ui guidelines for that platform as much as you can (the order of the OK, Cancel button on dialogs, should you have an Apply button somewhere, should you have a toolbar, etc.). Usually that's quite a bit of coding, and most people don't bother. At the end of the day: whatever you do, it doesn't matter since somebody probably was worse. Hey, at least you cared enough to ask around . Volguus fucked around with this message at 01:22 on Jan 4, 2014 |
# ? Dec 31, 2013 20:36 |
|
I'm getting null pointers in Java in the weirdest spots and can't figure it out. Here's the trace: code:
Java code:
Can anyone point out where the problem might be occurring?
|
# ? Jan 9, 2014 23:33 |
|
Are you sure its not just the first line and the argument text isn't null? I'd bet thats the problem.
|
# ? Jan 10, 2014 00:05 |
|
|
# ? Jun 12, 2024 03:54 |
|
Make sure the compiled version of the code is actually the latest, so the line numbers match the source. I, too, would guess the problem happens if text is null.
|
# ? Jan 10, 2014 01:57 |