|
I am a stupid and don't know how to delete posts.
tyang209 fucked around with this message at 16:02 on Nov 10, 2011 |
# ? Nov 10, 2011 15:55 |
|
|
# ? May 23, 2024 06:47 |
|
tyang209 posted:I can't use next() without getting this error and the program should compile. This should compile as I grabbed this off my course website as an example program and it did compile on Dr Java for Mac but I'm getting that ambiguous invocation error on my PC. Totally confused as to why. Could anyone drop some knowledge on me? DrJava is doing its own type-checking and is getting it wrong. I think it's getting confused with T next() in Iterator<T> and the overriding method String next() in Scanner, which implements Iterator<String> Are you required to use DrJava? Eclipse and Java 7 should do almost everything DrJava does if you can google the UI.
|
# ? Nov 10, 2011 21:30 |
|
Thought I'd be smart and try to use Spring's ridiculously simple dependency/property value injection for the purpose of passing in a property and seeing if we're in production, so the following:code:
|
# ? Nov 11, 2011 03:38 |
|
Use different values in development and production builds?
|
# ? Nov 11, 2011 15:50 |
|
You mean everyone doesn't use a server variable called ServerEnvironment ?
|
# ? Nov 11, 2011 22:21 |
|
cenzo posted:You mean everyone doesn't use a server variable called ServerEnvironment ? LOL, yes ideally software shouldn't require environment variables to be set just-so, unfortunately if this is your expectation then your heart will be broken over and over and over again. It has been a while since I've done Spring, but I'm pretty sure we used to just use PropertyPlaceholderConfigurer with ignoreUnresolvablePlaceholders on to load (or not load) various properties files into Java system properties, and then used System.getProperty(key,defaultValue) to revert to a default value if a certain property was not found.
|
# ? Nov 11, 2011 23:18 |
|
Paolomania posted:LOL, yes ideally software shouldn't require environment variables to be set just-so, unfortunately if this is your expectation then your heart will be broken over and over and over again. ignoreUnresolvablePlaceholders is probably what he wants. I don't know what will happen however, when the annotation attempts to "dereference" the property. It will probably explode at runtime.
|
# ? Nov 12, 2011 01:34 |
|
I apologize if this has been asked before because this is a huge thread, but here goes... I'm using PDFBox to extract text out of PDFs. Some PDF files are giving me trouble, like this one: http://www.atmel.com/dyn/resources/prod_documents/11100S.pdf PDFBox considers that file "encrypted" and requires a password to decrypt it. Yet I can use a page like this: http://pdf2html.tabesugi.net:8080/ and extract the text no problem. What am I missing here? Is it possible to extract the text using PDFBox with no password, and I've just overlooked it? EDIT: It is completely possible to do this with PDFBox. The sample application for PDFBox does this, and I even included the stupid bouncy castle jars in my classpath. The problem was that my ant buildscript somehow did not get updated to include the bouncy caste jars... ARRGGG. Everything works fine now! My Rhythmic Crotch fucked around with this message at 17:51 on Nov 13, 2011 |
# ? Nov 13, 2011 17:03 |
|
Paolomania posted:LOL, yes ideally software shouldn't require environment variables to be set just-so, unfortunately if this is your expectation then your heart will be broken over and over and over again. My world, it has been destroyed. Next you guys will tell me you log to somewhere other than sysout! If you do this thing, I might (joke) Seriously though, I thought it was kind of elegant to be able to have an entire app function on a different deployment level (prod,test,int etc) just by changing 1 variable. Upon reflection, I suppose that should probably be done at build-time. This thread, it always delivers.
|
# ? Nov 14, 2011 17:55 |
|
cenzo posted:My world, it has been destroyed. You're correct, at build time it should be determined what environment that build will run on. What you can do however (to make your life easier) use a build tool such as ant or maven, that when it has a certain variable passed it will know if it's for prod or for debug or for testing. And build the application that way. With ant for example, you can do something like: "ant -Ddeployment=prod" to set the "deployment" property in the build.xml file to value "prod". And in the build.xml do whatever you have to do when compiling for prod.
|
# ? Nov 14, 2011 22:14 |
|
I have a question about hibernate and XToMany relationships. It is an old story how the hibernate guys broke a lot of code with the 3.2 release with their new treatment of the "bags" (@OneToMany relations that are lists without an index). And they had a good reason for it as well, as a guy explains in his blog: http://blog.eyallupu.com/2010/06/hibernate-exception-simultaneously.html . On the forums, however, they haven't been helpful (or at least i haven't found the posts where they have), to explain to people how should they implement their relationships. The most common answer I've seen on the forums from the devs is to use a Set. I can see their reasoning, and it's a sound one. However, using a Set poses a different set of problems (namely, one cannot just add children to the parent without an ID set. That is...before the children are saved). Here is my situation: code:
However, this way obviously doesnt work when I want to fully load a show: code:
Now, there are many ways to skin this cat:
Finally my question: what is the "best" way to do this? How did you guys do this when you had this problem? I am aware that the "best" way may as well be an "depends", still I would like to know what maybe other approaches should I consider here?
|
# ? Nov 15, 2011 05:24 |
|
Hey everyone, I'm back with another super noob question.code:
|
# ? Nov 15, 2011 23:42 |
|
Ok so I need to make a method that normalizes an array of doubles. The teacher said it should set the first element to 0, and the last one to 1. I can't seem to get it to work for the SpecChecker( A JUnit test written to auto-grade us). Here's my code: code:
normalize fails to normalize: arrays first differed at element [0]; expected:<1.0> but was:<0.0>
|
# ? Nov 16, 2011 00:32 |
|
Pretty sure you want the first element to be 1.0 and the last element to be 0.0, you've got it backwards.
|
# ? Nov 16, 2011 02:20 |
|
Akarshi posted:
What happens here, when counter is arr.length - 1, and j is something larger than 0?
|
# ? Nov 16, 2011 04:53 |
|
rhag posted:
Well, instead of setting FetchMode.JOIN on both of the relations, will your app get killed by setting one to FetchMode.LAZY? I just tested it myself and it seems to be happy, but I don't know what kind of processing you're doing after you get the entities.
|
# ? Nov 16, 2011 05:32 |
|
Aleksei Vasiliev posted:Pretty sure you want the first element to be 1.0 and the last element to be 0.0, you've got it backwards. No, it was suppose to be 0 to 1. I just had it wrong. You had to minus the minimum, then divide by the max minus the min.
|
# ? Nov 16, 2011 06:20 |
|
TRex EaterofCars posted:Well, instead of setting FetchMode.JOIN on both of the relations, will your app get killed by setting one to FetchMode.LAZY? Well, i need the entire data for a web page. If I lazy fetch (as i normally would do), i obviously would get the error that i don't have a transaction started. Since, by the time the TVShow object gets to the web page, the transaction has already been committed long time ago. Therefore, it only makes sense to load the objects that i know I'll need, since i know that i won't be able to get to them after the transaction closed. If i set one collection to be lazy loaded, I would have to do a loop in the DAO to get the second collection. No, the application wouldnt get killed, it's just ugly. There are a lot of "ugly" ways of fixing the problem,I am under the impression that i'm missing something. A more elegant, nicer and ultimately easier (for now and future maintenance ) way of doing this. But, it could be that there isnt anything that can be done about it.
|
# ? Nov 16, 2011 17:43 |
|
rhag posted:Well, i need the entire data for a web page. From what I understand , this is a bug in hibernate that is set to WONTFIX. I suppose you could always try another JPA provider if you haven't polluted your classes with hibernate's droppings.
|
# ? Nov 16, 2011 20:41 |
|
I know there's a brief overview of a few IDEs on the first page, but I was hoping to get a little more information on Netbeans VS Eclipse. I'm still a student, and when I took a Java course we used NetBeans. I'm taking a Design Patterns course this semester which is also in Java and the professor only lets us use Eclipse. So far, I'm not impressed with it at all- the intellisense seems slow as hell, unconventional hotkeys (at least, compared to what I'm used to) and just all around I don't feel comfortable in the environment. Goons, why you do prefer one over the other?
|
# ? Nov 18, 2011 22:51 |
|
Sab669 posted:I know there's a brief overview of a few IDEs on the first page, but I was hoping to get a little more information on Netbeans VS Eclipse. You shouldn't be forced to use either in a design patterns course. Ultimately, either IDE is useful to whatever you learned and how well you know it. However, I prefer Eclipse because in general it is snappier for me. In fact, Eclipse originally was a huge breath of fresh air in terms of speed back when Netbeans was still known as Forte. I would also say Eclipse has a git plugin that work. However, there are times I am known to open Netbeans to do something because it is easier in Netbeans. I would kill for an IDE which had a fully working emacs mode just as if I was using emacs.
|
# ? Nov 18, 2011 23:26 |
|
Sab669 posted:I know there's a brief overview of a few IDEs on the first page, but I was hoping to get a little more information on Netbeans VS Eclipse. HFX posted:I would also say Eclipse has a git plugin that work.
|
# ? Nov 18, 2011 23:49 |
|
Sedro posted:Depending on your definition of "works". I know which one you are talking about. I would not define that as works. You are correct, that Netbeans does have great Maven support and a worthwhile reason to use it. I end up using the command line because the Eclipse plugins are so terrible.
|
# ? Nov 18, 2011 23:57 |
|
HFX posted:I know which one you are talking about. I would not define that as works. If it's any consolation the mercurial plugin for NetBeans loving owns. If I rename a or move a file it will also do an hg rename. It makes refactoring code 100% easier than before. One of my favorite little features is CTRL+ALT clicking an interface and having it show me the list of implementing classes. The only bug I frequently encounter is that the index doesn't get updated after fixing a compilation bug and having it mark the file in red. I have to delete my users .netbeans/var/cache/index folder completely for it to go away.
|
# ? Nov 19, 2011 00:06 |
|
Sab669 posted:Goons, why you do prefer one over the other? The correct answer is IntelliJ Community Edition.
|
# ? Nov 19, 2011 00:54 |
|
MEAT TREAT posted:One of my favorite little features is CTRL+ALT clicking an interface and having it show me the list of implementing classes. Eclipse's CTRL-T is probably a close, also there's a method call hierarchy view for answering "who's calling this method from the wrong place". I think the feature I like the most in Eclipse is its perspectives, which provide distinctive yet flexible layouts for different tasks. So the editing perspective empathizes the overall structure of the code, debugging perspectives is about the execution details of the code and the version control perspective is for reviewing incoming and outgoing changes.
|
# ? Nov 19, 2011 04:49 |
|
Is there any way to display a message to a user if something is missing from the classpath? Scenario is: GUIApp.jar lib\lib1.jar lib\lib2.jar lib\lib3.jar If any of the libraries are missing, the GUI will simply fail to appear with no message. Running it with java -jar will of course show the stacktrace, but is there any way to make it pop up a message saying "Hey you're missing these files"? The libraries are defined in the manifest, if that matters. And the GUI is Swing.
|
# ? Nov 19, 2011 05:50 |
|
The easiest way to deal with that is to catch the ClassNotFoundException and display the error dialogue in the corresponding catch block.
|
# ? Nov 19, 2011 06:16 |
|
Thanks, this worked!code:
|
# ? Nov 19, 2011 06:33 |
|
Does anyone know why when i implement the following method to recenter the cursor in response to mouse movement, it prevents the sprite assigned to it from receiving the mouse event (i.e. the sprite stays completely static)?code:
Partyworm fucked around with this message at 20:42 on Nov 20, 2011 |
# ? Nov 20, 2011 15:46 |
|
Has anyone used the Maven m2e eclipse plugin lately? I'm getting this error in the POM when using the webapp-javaee6 archetype (the other webapp archetypes seem ancient): code:
code:
|
# ? Nov 20, 2011 22:14 |
|
I'm new to java and need to get a web server running with tomcat and maven on a Mac. anyone have suggestions for getting up and running with relatively little pain?
|
# ? Nov 21, 2011 05:09 |
|
All you need to do to run Tomcat on a Mac is extract the archive and run scripts/startup.sh
|
# ? Nov 21, 2011 05:32 |
|
Lysidas posted:The correct answer is IntelliJ Community Edition.
|
# ? Nov 21, 2011 09:58 |
|
pigdog posted:This is the correct answer. It's stable, fast, free (CE), and has good usability. It's pretty impressive how fast a proficient person can code with it. For just Java you don't particularly need the commercial version, either. It's SVN support is piss poor though and has resulted in a poo poo ton of integration problems when other devs are using command line SVN. It also has occasional problems with caching things that has resulted in a couple of truly debugging sessions. I like it better than Eclipse though and Netbeans to me is crap due to the user interface.
|
# ? Nov 21, 2011 16:55 |
|
Hey folks, I haven't written anything in Java in forever and I've been cruising through my old notes catching up. Using Eclipse hasn't given me any issues yet, but It might be an Eclipse issue I guess - I never really used it before. Things have been going really well but I ran into the following example that I guess was working at one time involving reflection (what it's trying to do doesn't matter, doesn't even get to that point yet): package ReflectionEx; import java.lang.reflect.*; public class Field2 { public double d; public static void main(String args[]) { try { Field2 f2obj = new Field2(); Class<?> cls = Class.forName("Field2"); Field fld = cls.getField("d"); System.out.println("d = " + f2obj.d); fld.setDouble(f2obj, 12.34); System.out.println("d = " + f2obj.d); } catch (Throwable e) { System.err.println(e); } } } Running this I get a "java.lang.ClassNotFoundException: Field2" on the "Field2 f2obj = new Field2();" line. Seems like it should see it. I have everything typed correctly I think... so I'm not quite sure. Might be something silly.
|
# ? Nov 25, 2011 07:19 |
|
Try ReflectionEx.Field2. Any time you're referring to a Class by its name, you need to fully qualify it rather than letting the computer decide whether you're really trying to reflectively get the class for java.awt.List or java.util.List.
|
# ? Nov 25, 2011 07:54 |
|
1337JiveTurkey posted:Try ReflectionEx.Field2. Any time you're referring to a Class by its name, you need to fully qualify it rather than letting the computer decide whether you're really trying to reflectively get the class for java.awt.List or java.util.List. I never really considered that and it absolutely worked. Makes sense. Brilliant - Thank you.
|
# ? Nov 25, 2011 15:53 |
|
Another stupid Java question: Is there something I can do in Eclipse so that I don't have to include the library path when I'm launching a jar? What I mean is this: code:
|
# ? Nov 26, 2011 17:47 |
|
|
# ? May 23, 2024 06:47 |
|
hootimus posted:Another stupid Java question: You should just be able to add external JARs to your project. Right-click on your project and I think it's under "Source" there should be an option to add an external JAR.
|
# ? Nov 26, 2011 22:29 |