|
ahmeni posted:Are heap dumps with tools like jmap very useful from our operations non-developer perspective? Yes, large leaks can sometimes be very obviously traced back in the tools to a single map, classloader, etc that will very much get you in the neirhborhood of the culprit. The ops guys might need to pair up with a JVM guru the first few times to understand the tools you have available, but it is not anything like source-level debugging.
|
# ? Nov 1, 2013 14:38 |
|
|
# ? Jun 12, 2024 02:23 |
|
As an operations engineer who supports java applications the biggest thing I'm looking for when I load up jmanage are obvious memory or connection leaks related to recent code deploys. If I can't pin it down to something obvious I'm dropping it. We operations folks don't usually have a ton of time to spend picking at a problem in code.
|
# ? Nov 1, 2013 15:05 |
|
Is there a way, using the java.awt.Desktop, or something very similar, to select a file? I can use Desktop.open() to open to a file location in Windows, but then I want it to select a particular file in that directory.
|
# ? Nov 4, 2013 22:37 |
|
mister_gosh posted:Is there a way, using the java.awt.Desktop, or something very similar, to select a file? Seems like you can do that by launching explorer with the /select option: explorer.exe /select,"C:\Folder\subfolder\file.txt" Copied from: http://stackoverflow.com/questions/13680415/how-to-open-explorer-with-a-specific-file-selected
|
# ? Nov 4, 2013 22:52 |
|
Rexxed posted:Seems like you can do that by launching explorer with the /select option: Thanks!!
|
# ? Nov 4, 2013 23:06 |
|
Any one know of any java classes that do the same things (or similar) to this Python script? (Creating Human readable UUIDs) https://github.com/zacharyvoase/humanhash BexGu fucked around with this message at 22:00 on Nov 5, 2013 |
# ? Nov 5, 2013 21:44 |
|
BexGu posted:Any one know of any java classes that do the same things (or similar) to this Python script? (Creating Human readable UUIDs) Google is turning up like 2 people who have done a Bubble Babble assignment. Beyond that, you might be best off reimplementing that Python script on your own.
|
# ? Nov 5, 2013 22:23 |
|
Hello! I'm a PHP developer who would like to get into Java web programming. I'm just not sure where to start. The Java world is pretty huge. Do I need to learn Ant, Maven, or Gradle? Should I start with one of the many web frameworks out there, or do something more low level? And what is low level? Servlets? JSP? I'm not sure what the difference is. And if I pick a framework, it seems that some need a container like tomcat to run and others can be their own container, is that a big factor? I learned Java syntax in school but we did simple GUI and data structure stuff, we never needed a build tool besides what Eclipse could do for us. Trying to make something real in Java looks like a daunting task. I want to stick with web stuff since that is what I know, but I don't know where to start.
|
# ? Nov 6, 2013 01:19 |
|
mister_gosh posted:Is there a way, using the java.awt.Desktop, or something very similar, to select a file? Why do you need to do this? The suggestion with launching explorer.exe works, but what is the reason for such a requirement? Going this route opens up a potential can of worms. I know that now all your clients are using windows xp 32 bit, but what if in the future they'll go to something better? They'll run your app on a Mac? Or ... even worse, Linux? And they'll want this exact feature there? What do they want to do with explorer and the file once they have it selected? Open it up in the default editor? Desktop.open will do that for you. Copy it somewhere? You can provide that feature yourself. If there would be a way to make your client happy without launching explorer.exe, try to go that route. The pain maintaining such a thing is usually not worth it.
|
# ? Nov 6, 2013 14:02 |
|
We have a content management system with a Swing interface. 95% of users work is done within the GUI, but there's a small percentage of the time where they need to go to the local location of the file they are working with (which are all resident on their system). The reason could be anything. So I'm putting in an option to right click on the file to show it in Windows explorer (all users are Windows). Rather than just Desktop.open() the directory the file is in, it seems ideal to select it. I could detect whether it is Windows and only do the select if it is Windows, but it's unnecessary as this is very internal. One example might be that they may have a graphic file or an html file they want to open in an editor different from their default editor. Ideally we'd never allow them access but there are third party tools and other environments that our users work with, and we can't limit them to finding their source files.
|
# ? Nov 6, 2013 16:43 |
|
PlesantDilemma posted:Hello! I'm a PHP developer who would like to get into Java web programming. I'm just not sure where to start. The Java world is pretty huge. Do I need to learn Ant, Maven, or Gradle? Should I start with one of the many web frameworks out there, or do something more low level? And what is low level? Servlets? JSP? I'm not sure what the difference is. And if I pick a framework, it seems that some need a container like tomcat to run and others can be their own container, is that a big factor? Java and its eco system is loving huge and trying to digest it all at once isn't really feasible. Pick a project you want to do (or port one of your PHP projects) and just bang away at it and pick it up as you. To answer your questions I would just start with Maven, Ant can be learned in a pinch if needed, I haven't used Gradle so I can't comment on that. Servlets are pretty much the lowest you can go. A JSP is a view and would be close to your .php file but it is generally frowned upon to put processing in them, you should use JSTL (I think, haven't been in the web game outside of services in a while) Just use Tomcat, it will suit must of your needs. Once you go corporate you may need to switch to JBoss but Tomcat will be a good base.
|
# ? Nov 6, 2013 17:23 |
|
mister_gosh posted:...(all users are Windows)... This is true today. It will be true tomorrow. The day after ... it may not. But, if you have to do it, then well, do what you gotta do. I'm not saying to prevent them from accessing their files, was just thinking that there may be a better way of providing them with the features that they want, instead of going native. With long lived projects (5+ years), when features like this creep into it, it becomes a nightmare to maintain for future developers. It may be better (from design perspective) to go the JNI route, and do whatever you need to do from native code, and just keep the java code clean. Such that when other OS-es will be used, the developers would just need to provide the library for that OS, that will implement the required native functions. From a different perspective: if all my clients are windows, they will always be windows and they will never ever change, why do I need to write my UI in java then? Going native would provide them with a much more responsive interface. Of course, the downside could be that developers may not be familiar with C/C++ windows programming, but that can be learned. It's not magic. But, the explorer.exe solution is the easiest and the fastest one to implement.
|
# ? Nov 6, 2013 17:47 |
|
lamentable dustman posted:Java and its eco system is loving huge and trying to digest it all at once isn't really feasible. Pick a project you want to do (or port one of your PHP projects) and just bang away at it and pick it up as you. Agreed with everything you just said but I would recommend GlassFish over Tomcat for someone just starting out today. The concepts you learn will port over well to any of the other servers, butt the admin console is a lot easier to use and understand at first and don't require loving around with XML configs until you need to configure very advanced features. ALso there are plugins for it just like Tomcat in every IDE which will help with deploying your projects straight from the IDE.
|
# ? Nov 6, 2013 19:10 |
PlesantDilemma posted:Hello! I'm a PHP developer who would like to get into Java web programming. I'm just not sure where to start. The Java world is pretty huge. Do I need to learn Ant, Maven, or Gradle? Should I start with one of the many web frameworks out there, or do something more low level? And what is low level? Servlets? JSP? I'm not sure what the difference is. And if I pick a framework, it seems that some need a container like tomcat to run and others can be their own container, is that a big factor? I haven't used it before, but the Play Framework seems like a good way to hit the ground running.
|
|
# ? Nov 6, 2013 19:19 |
|
fletcher posted:I haven't used it before, but the Play Framework seems like a good way to hit the ground running. Play and other big frameworks like Spring are very popular, but they're also gigantic. From what I've seen they have a lot of dependencies and use a whole lot of their own way of thinking, so if you're going to subscribe to one of those, you're getting pretty deep into custom APIs and you're going to be married at the hip. Not that that's the end of the world. But if you're just trying to learn some basic Java web stuff, I'd honestly start with just throwing together some JSPs. Then write some servlets to drop in Tomcat. Then maybe you wanna learn Play. Hard NOP Life posted:Agreed with everything you just said but I would recommend GlassFish over Tomcat for someone just starting out today. The concepts you learn will port over well to any of the other servers, butt the admin console is a lot easier to use and understand at first and don't require loving around with XML configs until you need to configure very advanced features. ALso there are plugins for it just like Tomcat in every IDE which will help with deploying your projects straight from the IDE. I've used Tomcat and JBoss a lot more, but from what I've seen GlassFish is pretty dang cool, like you said the admin console is just simpler to use and more robust. They're all fine really. Zaphod42 fucked around with this message at 22:37 on Nov 6, 2013 |
# ? Nov 6, 2013 22:34 |
|
fletcher posted:I haven't used it before, but the Play Framework seems like a good way to hit the ground running. Holy poo poo man Play Framework is the exact opposite of baby's first Java web, it's a huge framework of java, scala, sbt and plugins. It runs its own webserver instead of using the standard WAR packaging system, it's as far away from the standard java ecosystem as you can get. Learn Servlets and JSPs first they are the building blocks that everything else is built on, then get into frameworks like Spring, Struts 2 or Wicket.
|
# ? Nov 6, 2013 22:49 |
Hard NOP Life posted:Holy poo poo man Play Framework is the exact opposite of baby's first Java web, it's a huge framework of java, scala, sbt and plugins. It runs its own webserver instead of using the standard WAR packaging system, it's as far away from the standard java ecosystem as you can get. Yeah you're right, probably not the best way to start out. From what I had heard about it it kinda sounded like Django for Java.
|
|
# ? Nov 6, 2013 23:05 |
|
Yeah Play is different in that it tries to break away from the Java EE system of requiring an application server to host your application by bundling it's own web stack. I'm convinced that the motivations for it amount to nothing more than "gently caress You Dad, our way is cooler!", but that just might be my YOSPOS leaking, either way it looks cool and I'll have to delve more deeply into in the near future.
|
# ? Nov 6, 2013 23:22 |
|
fletcher posted:Yeah you're right, probably not the best way to start out. From what I had heard about it it kinda sounded like Django for Java. Yeah its like Django or Rails for Java.
|
# ? Nov 6, 2013 23:31 |
|
Hard NOP Life posted:Learn Servlets and JSPs first they are the building blocks that everything else is built on, then get into frameworks like Spring, Struts 2 or Wicket. I'm gonna go with this. If anyone knows some good servlet/jsp tutorials feel free to post them. I'm gonna fire up Eclipse and see what google search can teach me.
|
# ? Nov 7, 2013 01:18 |
|
PlesantDilemma posted:I'm gonna go with this. If anyone knows some good servlet/jsp tutorials feel free to post them. I'm gonna fire up Eclipse and see what google search can teach me. Getting a book (i cannot recommend any, just pick one, if they got published they cannot say bullshit in there) may be a good idea also. As for tutorials I would start with the reference one: http://docs.oracle.com/javase/tutorial/ and go from there.
|
# ? Nov 7, 2013 01:38 |
|
Hard NOP Life posted:Yeah Play is different in that it tries to break away from the Java EE system of requiring an application server to host your application by bundling it's own web stack. I'm convinced that the motivations for it amount to nothing more than "gently caress You Dad, our way is cooler!", but that just might be my YOSPOS leaking, either way it looks cool and I'll have to delve more deeply into in the near future. Play is based off of Netty, which is a particularly awesome asynchronous networking engine based on Java's NIO API (non blocking IO). Unlike node.js, Netty actually has threads and poo poo, and is very solid - I believe many hedge funds and some of the rest of the financial sector use it for realtime stuff. To my recollection, Play also does fancy things with making requests isolated from each other, i.e. making even static variables thread-local so that requests can pause when they're blocked on IO and such and be resumed later with ease. It's not necessarily going to get more absolute throughput, but depending on the workload, responsiveness may improve on top of Play. They used to use ECJ (Eclipse's java compiler in library form) to compile code on demand, which they also manipulated the bytecode of, I think.
|
# ? Nov 7, 2013 04:56 |
|
I thought I understood try-catch blocks, but I'm thinking I don't fully get them after trying to implement my own. I know that try-catch blocks must surround such object calls such as instantiating a new FileInputStream or reading from the stream. In fact, if try-catch isn't present then Eclipse will refuse to compile. But ArrayList will throw an index out of bounds exception when necessary, but Eclipse doesn't seem to give two shits about not surrounding ArrayList calls with try-catch. Does that make sense at all? So... when are try-catch blocks required by methods that throw exceptions and when are they not? I am trying to implement a data structure and I want to throw my own exceptions but I don't want users to have to use try-catch blocks. Sorry if it's unclear what my question is. ArrayList throws exceptions at times, so does FileInputStream. But Eclipse won't complain about no try-catch block with ArrayList. What gives? Am I missing something glaringly obvious? Also, Firefox wants to autocorrect FileInputStream to milkstream, ha!
|
# ? Nov 11, 2013 12:57 |
|
What you want are unchecked exceptions. You might also want to read this before you actually decide to use them though: http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html
|
# ? Nov 11, 2013 13:08 |
|
Tamba posted:What you want are unchecked exceptions. Good deal, thanks for those. I learned a lot reading through, and now I have some good bookmarks. It looks like the data structures already provided in the standard library throw exceptions that inherit RuntimeException, which makes them unchecked.
|
# ? Nov 11, 2013 14:47 |
|
Woodsy Owl posted:Good deal, thanks for those. I learned a lot reading through, and now I have some good bookmarks. It looks like the data structures already provided in the standard library throw exceptions that inherit RuntimeException, which makes them unchecked. Yeah, exactly. Unchecked exceptions can be kinda confusing when you're learning exception handling for the first time. Runtime Exception for instance is supposed to be things that can't be predicted at compile-time, so its not worth making the compiler enforce them. Lots of time Runtime Exceptions mean things are so fubar you're just going to crash anyways and there's no real graceful way to handle it. Also, (you probably already know this) you can always declare that your method throws the exceptions that the code it uses throws, and then it isn't responsible for having a try/catch block to handle those exceptions. Instead, if it gets an exception, it'll just pass it up the stack to the nearest calling method which DOES have a try/catch block to resolve the code. Lots of times this is actually the behavior you want. It depends upon what level of the code you're in and how intelligent / error correcting you want that code to be. So your Main function could call method A, which calls method B, and B throws an Exception. A doesn't try/catch it, it simply throws it up, so Main ends up catching the exception and prints out a handy error message to the user to let them know something went wrong (like their internet is disconnected). Exceptions should be typed when possible, just saying catch(Exception e) all the time is bad practice. Oh and don't ever loving write this: code:
or this code:
Zaphod42 fucked around with this message at 21:11 on Nov 11, 2013 |
# ? Nov 11, 2013 21:07 |
|
Thanks loads mate, I really appreciate it!
|
# ? Nov 12, 2013 09:24 |
|
If you don't want to handle an exception in some parts of your code, it is almost always better to encapsulate it. code:
|
# ? Nov 12, 2013 14:08 |
|
... but make sure you pass the original exception as cause, as in code:
code:
|
# ? Nov 12, 2013 15:14 |
|
The Guava Throwables library has a nifty convenience operation for this use case:Java code:
Java code:
|
# ? Nov 12, 2013 19:38 |
|
Gravity Pike posted:The Guava Throwables library has a nifty convenience operation for this use case: I hate that. Spring does that poo poo of converting all exceptions into runtime, and it loving sucks. Say what you will about the merits of checked vs. unchecked exceptions, but there's a reason they exist, so that any calling code knows what it's dealing with.
|
# ? Nov 13, 2013 00:49 |
|
I mean, absolutely, there is a science to propagating exceptions, and generally wrapping everything in a RuntimeException is the wrong thing to do. On the other hand, we have UnsupportedEncodingException. It is checked, and explicitly gives me a chance to react to it. Now, I'm asking for UTF-8. I know that I have access to UTF-8. It is utterly unreasonable to force everything at a higher level to deal with the possibility of an UnsupportedEncodingException. But it is also insanely unsafe to write code that would just swallow this exception, even though I know it'll never actually be thrown. So I wrap it in a RuntimeException, and get to ignore it, and still feel confident that the system isn't ignoring it, and it'll bubble up to a point where someone (the server framework, usually) will transform it into a useful response. (500 Server Error) (If you take issue with UnsupportedEncodingException in this instance, feel free to substitute NoSuchAlgorithmException.) The law of the land is to propagate checked exceptions that calling code has a reasonable expectation of being able to recover from. If one of my arguments is the encoding, yeah, pass along that Exception so maybe my caller can ask for a different one. But if you just bubble up every possibly thrown exception in your method signature, you're preventing your users from seeing what is actually likely, and obscuring their options for recovering from any given exception.
|
# ? Nov 13, 2013 01:22 |
|
Of course, in cases where you *know* that you won't actually throw the checked exception (and there are many such cases), then do what you want. It just looked like you were advocating the Spring approach of wrapping *all* exceptions as runtime, which I still say loving sucks.
|
# ? Nov 13, 2013 07:36 |
|
Kilson posted:Of course, in cases where you *know* that you won't actually throw the checked exception (and there are many such cases), then do what you want. It just looked like you were advocating the Spring approach of wrapping *all* exceptions as runtime, which I still say loving sucks. What's wrong with having only runtime exceptions? Thats how new languages like c# handle exceptions. Checked exceptions have caused more pain and harm and general misuse than any other feature. All it takes is a @throws declaration in the comments and anyone whose calling your method can choose to handle a runtime exception or ignore it.
|
# ? Nov 14, 2013 17:09 |
|
FateFree posted:What's wrong with having only runtime exceptions? Thats how new languages like c# handle exceptions. Checked exceptions have caused more pain and harm and general misuse than any other feature. All it takes is a @throws declaration in the comments and anyone whose calling your method can choose to handle a runtime exception or ignore it. What's wrong is how this choice gets presented, or rather usually doesn't get presented. Even if I could trust a library author to always follow the @throws documentation convention, I'd still prefer to make the choice by answering one question:
Instead of having the correct documentation at hand, having it open, having it open in the right place, scanning the documentation for one particular keyword, then typing the code myself based on what I've chosen.
|
# ? Nov 14, 2013 17:56 |
|
wrong thread..
DholmbladRU fucked around with this message at 20:18 on Nov 14, 2013 |
# ? Nov 14, 2013 20:08 |
|
I don't suppose anyone could quickly tell me why my servlet that is generating a HTML image code isn't working? It's generating the first and last parts, but it's not generating the folder and I honestly have no idea why (I double checked all the sql) and eclipse is not informing me of any obvious errors. Thanks in advance!quote:Statement stmt2 = con.createStatement(); quote:<img src="http://galleryurl/folder/BIGshot.bmp"> Is what it currently generates and the bolded is what is missing. It must be obvious but I just can't see it! Or, the code itself might not be faulty, it just isn't remembering what 'category' is. edit2: Solved. A Tartan Tory fucked around with this message at 21:09 on Nov 14, 2013 |
# ? Nov 14, 2013 20:54 |
Shouldn't mix database access and presentation like that. Also need to close your database resources when you're done with them using a try/catch/finally. Also don't use string concatenation to build SQL statements, use prepared statements instead to avoid SQL injection attacks.
|
|
# ? Nov 14, 2013 21:06 |
|
fletcher posted:Shouldn't mix database access and presentation like that. Also need to close your database resources when you're done with them using a try/catch/finally. Also don't use string concatenation to build SQL statements, use prepared statements instead to avoid SQL injection attacks. This is just me loving around trying to learn the absolute basics, but thanks for the input! I did find out what wasn't working though and it was that I forgot to add in my session management in that servlet and therefore it had no loving idea what 'category' was.
|
# ? Nov 14, 2013 21:08 |
|
|
# ? Jun 12, 2024 02:23 |
|
Another small question if I can get away with double posting this once. I'm now trying to make a dynamically generated table using SQL and java by doing the following.quote:try { However, I have a feeling my SQL is balls, because I keep getting exceptions when trying to use statistics.accessdata, pictures.ShortName, categories.ShortName from my container jcg. Can anyone give me an example of an SQL query that would work in this situation, to call up accessdata and the two different shortnames and then create a table displaying them ordered by the accesscount integer?
|
# ? Nov 14, 2013 22:26 |