|
Tesseraction posted:What operating system / IDE (if any) are you using? Ubuntu 13.04, no IDE. I'm running code:
|
# ? Jun 30, 2013 01:27 |
|
|
# ? May 20, 2024 07:57 |
|
I may be wrong, but if you use -classpath don't you have to put the path into double quotes? I think no double quotes is with -cp for the short version.
|
# ? Jun 30, 2013 15:39 |
|
Tesseraction posted:I may be wrong, but if you use -classpath don't you have to put the path into double quotes? I think no double quotes is with -cp for the short version. No: Python code:
code:
|
# ? Jun 30, 2013 16:04 |
|
Whats the current state of the art for Java desktop apps? Still Swing? If so, how native can you get them to look?
|
# ? Jul 3, 2013 19:29 |
|
At work I'm dealing with a platform that consists out of many components (all java applications). Some components expect other components to be up and runnning before they are started, so we need to start/stop components in a specific order. Currently we use a bunch of horribly convoluted bash scripts to achieve this. This solution works, but it ain't pretty and I hate using bash for stuff this complex. What I need is a way to declare dependencies between components (A must be started before B can start), and a way to start/stop components which takes these dependencies into account (start B, oh wait, A isn't running, lets start A first) I've looked into OSGi, but making non-OSGi stuff OSGi compatible seems hard. Does anyone know a nice solution for this problem?
|
# ? Jul 3, 2013 19:35 |
|
Votlook posted:At work I'm dealing with a platform that consists out of many components (all java applications). On the other end of the spectrum, you could express those dependencies to make and then use make to start the applications.
|
# ? Jul 4, 2013 01:39 |
|
I want to do something fun this weekend, I'm thinking a little webapp. The stack probably looks something like: - mongo db - tomcat - java domain w/ core spring di - cucumber-jvm bdd tests - angularjs frontend But what's a good REST framework? I'm using spring MVC at work, it seems kind of heavyweight and doesn't conform to jax-rs. What's a better one, and how do you do unit tests for it?
|
# ? Jul 4, 2013 04:58 |
|
ancient lobster posted:I want to do something fun this weekend, I'm thinking a little webapp. The stack probably looks something like: Jersey. I myself am partial to Dropwizard for tinkering with REST stuff, which is a nice streamlined package of a lot of useful libraries and configuration.
|
# ? Jul 4, 2013 07:03 |
|
Doctor w-rw-rw- posted:Jersey. I myself am partial to Dropwizard for tinkering with REST stuff, which is a nice streamlined package of a lot of useful libraries and configuration. Second this, I just started a REST project at work and I'm using Jersey and loving it. Although all the really JAX-RS compliant implementations have almost identical annotations and API, so you can really swap between them. (RESTEasy, Apache CXF, Wink, Restlet although its a bit different because it was developed when JAX-RS wasn't fully finished) Jersey makes it pretty painless to get a REST web service to do whatever you want. And it plays nice with Tomcat. For unit testing, I wrote a simple client using the jersey.api.client.Client and have some JUnit tests. I also have a browser thingy to do automated testing that way, but I don't use it for REST as much as I do other projects, I'm just passing JSON which is easy to respond to programatically. Spring MVC is indeed very heavyweight, seemed like way overkill to me. If it matters I just reviewed all of these for work and concluded Jersey would be the best. Zaphod42 fucked around with this message at 16:18 on Jul 5, 2013 |
# ? Jul 5, 2013 16:11 |
|
Jerry SanDisky posted:Whats the current state of the art for Java desktop apps? Still Swing? If so, how native can you get them to look? But since MS at least is going all Metro even on desktop you can probably get that kind of look easier with JavaFx.
|
# ? Jul 5, 2013 19:25 |
|
I'm a computer science student who has primarily experience in C++ (no outside projects or anything, mostly just the stuff we learned in programming fundamentals 1, 2, and 3) and am trying to figure out java for the time being, using Stanford's java assignments. I am trying to do the 2nd part of this (the section about drawing a face): http://see.stanford.edu/materials/icspmcs106a/15-section-handout-2.pdf and am wondering if I could get a point in the right direction, as in which modules should I be using/what should I be importing and such, like I said, just a point in the right direction as we never did any kind of graphical anything in C++. BTW their solution doesn't work for me even when I import the correct java archive and add it to the classpath, so I was wondering more how you would go about drawing the face, not necessarily how Stanford wants it's students to.
|
# ? Jul 9, 2013 14:02 |
StdDraw is a really unoptimised drawing library that (I think) used to be part of the standard Java library. It's extremely intuitive, though, and requires hardly any setup, so I think it might be what you're looking for. Just import StdDraw.java when you compile your project and you should be good to go. (If you're using Eclipse this is literally as easy as copy-pasting it into your project folder.) It can be found here, with JavaDoc here. One thing to note, though, is that it draws within the coordinates x in [0;1] and y in [0;1]. Just something to keep in mind.
|
|
# ? Jul 9, 2013 15:07 |
|
I'm working with a project that uses JSF 1.2 and I do not understand how validation error handling works. I have a form with required input text field and a drop down menu that's optional. So here's the part that confuses me - if no value is selected in the optional drop down and validation fails, drop down will restore the initial value. This will not happen if something was selected. Why does it work like that and is there a way i could make this behavior uniform in both cases?
|
# ? Jul 10, 2013 13:11 |
|
I'm a bit stumped. I'm trying to turn an image I have as a Bitmap into a base64 String. The code I have works for small images but as soon as they get bigger than for example, this happens: The base64 I get (just as the image I posted) comes to exactly 4096 bytes and I doubt that's a coincidence. The code in question: Java code:
This is on Android but that shouldn't really make a difference.
|
# ? Jul 10, 2013 15:31 |
|
Sereri posted:I'm a bit stumped. I'm trying to turn an image I have as a Bitmap into a base64 String. The code I have works for small images but as soon as they get bigger than for example, this happens: Haven't done this in a long time but it's your ByteArrayOutputStream that is only reading the first 4096 bytes. You need to read it in chunks.
|
# ? Jul 10, 2013 16:48 |
|
Imazul posted:Haven't done this in a long time but it's your ByteArrayOutputStream that is only reading the first 4096 bytes. You need to read it in chunks. To offer additional advice, if I were to fix it, I might wrap the BAOS (abbreviated b/c I'm on a tablet) with a Base64OutputStream and then supply that to the compress method. Your BAOS now has a compressed, base64-encoded image. Then do what you will to read it out. Android makes a difference because it supplies the Base64OutputStream class. But yeah, make sure you pay attention to how much data is actually being written/read. Doctor w-rw-rw- fucked around with this message at 17:06 on Jul 10, 2013 |
# ? Jul 10, 2013 17:00 |
|
Imazul posted:Haven't done this in a long time but it's your ByteArrayOutputStream that is only reading the first 4096 bytes. You need to read it in chunks. Doctor w-rw-rw- posted:To offer additional advice, if I were to fix it, I might wrap the BAOS (abbreviated b/c I'm on a tablet) with a Base64OutputStream and then supply that to the compress method. Your BAOS now has a compressed, base64-encoded image. Then do what you will to read it out. Yeah that worked, thanks guys. It now looks like that: Java code:
before: after: Sereri fucked around with this message at 22:46 on Jul 10, 2013 |
# ? Jul 10, 2013 20:52 |
|
Joda posted:I've had good experiences working with Slick2D, but last I checked their site was down, and it might not be easy to get into without its Javadocs. Angryhead posted:I haven't used Pygame, but LibGDX is a great framework for Java. A couple pages back but, having used both, LibGDX is about a million times better than Slick. The community (IRC at least) is better, the documentation is better, the actual API itself is better, etc.
|
# ? Jul 11, 2013 07:50 |
|
Can someone tell me why I suck and therefore can't draw a Line.code:
|
# ? Jul 11, 2013 19:47 |
an skeleton posted:Can someone tell me why I suck and therefore can't draw a Line. I never worked with it myself, but looking at the JavaDoc for what I assume is the class you're trying to instantiate, it says the the constructer Graphics2D() is protected. I'm not sure how familiar you are with Java syntax, but the protected keyword means only the class itself and its subclasses can use the method (Or in this case the constructor.)
|
|
# ? Jul 11, 2013 19:52 |
|
Joda posted:I never worked with it myself, but looking at the JavaDoc for what I assume is the class you're trying to instantiate, it says the the constructer Graphics2D() is protected. Sorry if this is ignorant, but... how do I construct it then?
|
# ? Jul 11, 2013 19:54 |
|
an skeleton posted:Sorry if this is ignorant, but... how do I construct it then? You don't. Graphics2D is what's known as an abstract class; it's impossible to instantiate, because it isn't complete. The Java graphics interface is... not simple. I can find a tutorial for you if you want, but it's considerably more complicated than just importing a class or two.
|
# ? Jul 11, 2013 20:00 |
an skeleton posted:Sorry if this is ignorant, but... how do I construct it then? Keep in mind, that I'm unfamiliar with the conventions and use of Graphics2D. Looking at that javadoc a second time I see another big problem: Graphics2D is abstract, which means it is not meant to nor can be instantiated. Its only purpose is to be a superclass template to another class or tree of classes. Assuming this is the class you need to use, you probably need to use one of its subclasses, or use it in a vastly different way to what you're trying to.
|
|
# ? Jul 11, 2013 20:00 |
|
an skeleton posted:Sorry if this is ignorant, but... how do I construct it then? You'll be provided one by Java. Check this out, download the examples and look through them: http://docs.oracle.com/javase/tutorial/2d/basic2d/
|
# ? Jul 11, 2013 20:06 |
|
baquerd posted:You'll be provided one by Java. Check this out, download the examples and look through them: http://docs.oracle.com/javase/tutorial/2d/basic2d/ This is the case with repainting UI components like canvases and such. The other category is images. Here things can be a lot simpler in cases where a UI isn't needed. An uncompiled example to create a new image, draw to it and write it to a file: Java code:
|
# ? Jul 12, 2013 01:47 |
|
Does anyone have any decent resources for explaining to me how Java works? I mean, I'm solid with syntax, object-oriented-ness, various patterns, concurrance/threading, etc, but I have no idea what the ClassLoader is or does, other than "It's a tool I can use to get files from /src/main/resources". My knowledge of Java is purely from being dropped into the middle of it and figuring things out, rather than any formal education I've ever received. I feel like I'm a pretty solid developer, but I've just got some embarrassing holes in my background knowledge that I really should get around to filling in.
|
# ? Jul 12, 2013 02:24 |
|
Gravity Pike posted:rather than any formal education I've ever received. I can guarantee you that no one learned how the Java class loader works through "formal education". Like most implementation details most people know about it because they work on it or use it directly. A tiny part, like you, want to fill in gaps in their knowledge; so don't underrate yourself or your knowledge because frankly just knowing that it exists put you above most developers I know. But anyways to answer your question: dig in
|
# ? Jul 12, 2013 03:24 |
|
Yeah, the most that I ever got learning about the JVM through school is when my professor spent a few minutes comparing Java bytecode to x86 assembly in our assembly class.
|
# ? Jul 12, 2013 03:30 |
|
I have a custom TableModel which extends javax.swing.table.AbstractTableModel. In one of the columns I have a JLabel. When a user sorts on the column, they get a random assortment, due to the first parameter in the JLabel being blank (only a single icon gets displayed in the column). For example, there may be 6 rows with 2 having "icon_A", 2 having "icon_B" and 2 having "icon_C". If they sort on that column, they may get: icon_B icon_C icon_A icon_A icon_C icon_B code:
|
# ? Jul 16, 2013 21:21 |
|
Java Brainteaser! AKA How the JVM made me spend most of my morning questioning the mathematical underpinnings of the very universe... Two jar files have identical SHA-1 digests... code:
code:
God is dead. There is no truth. Reality is but a poorly rendered illusion stretched over a thin membrane of infinite lies. Answer: Some sysadmin who is no longer working here had instructed puppet to "helpfully" install a different version of the jdbc driver jar in the jvm ext directory without telling anyone, effectively creating a secret global classpath.
|
# ? Jul 16, 2013 21:27 |
|
mister_gosh posted:I have a custom TableModel which extends javax.swing.table.AbstractTableModel. In one of the columns I have a JLabel. Are you trying to sort on the JLabel text or something related to the icon? You might need to implement a TableRowSorter: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting
|
# ? Jul 17, 2013 05:20 |
|
Kruegel posted:Are you trying to sort on the JLabel text or something related to the icon? I was trying to sort on the icon (with a JLabel text having a null/blank value). Thank you! Got it working now.
|
# ? Jul 17, 2013 14:32 |
|
I've gotta make a game for my final in my summer Java course, and I'm having trouble "resetting' the game when you lose. I know init() should only be called once in an applets lifetime, so I gathered all the JPanel items, and adding and declaring into init(), and made a new function that initializes all my variables and started the thread. I then call that function from init() and from the reset button that appears on (so far, only certain) gameover conditions. When I click the reset button, things seem to go smoothly. My guy warps back to his starting spot, and the action resumes, but I either lose focus on the JPanel (even though I set it during the initialization function) or the KeyListener stops listening, I can't tell which. Anyone wanna take a gander and point me in the right direction? http://pastebin.com/77HzsMf8 (It's a snake game) (I haven't implemented the dots that will be eaten yet) StrugglingHoneybun fucked around with this message at 12:12 on Jul 18, 2013 |
# ? Jul 18, 2013 12:04 |
|
You call setFocusable() on the JPanel, which allows the component to be focused, but does not focus it. Looking through the documentation, you will probably need to call requestFocus() on the same JPanel whenever the reset button is pressed. http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#requestFocus()
|
# ? Jul 18, 2013 17:37 |
|
an skeleton posted:Can someone tell me why I suck and therefore can't draw a Line. Just to make this explicit, you'd get your Graphics context by calling a Component's getGraphics() function. You'd probably want to call it from a Canvas object in a JPane or some such. You can cast a Graphics object to Graphics2D with no issues.
|
# ? Jul 18, 2013 18:44 |
|
carry on then posted:you will probably need to call requestFocus() on the same JPanel whenever the reset button is pressed. That did it. Thanks so much!
|
# ? Jul 18, 2013 19:01 |
|
Audio always seems to be troublesome, Java audio doubly so. I've been doing a bunch of tinkering this afternoon and I made a couple of discoveries. code:
I also found out that while the standard Java stack can support Midi files fine (provided the host OS can play them), there's a several-second pause before the audio when you call Clip.play(). Is the midi being rendered to a buffer on-demand or something? Has anyone had experience working with MP3 or OGG decoding in Java? Right now I'm leaning toward JLayer, as it seems simple and straightforward. I would like to target standard J2SE 1.5 rather than dragging in JavaFX or anything else.
|
# ? Jul 20, 2013 22:48 |
|
Whenever I compile my noob little codes, I have to manually set the configuration to the current source. Example - I create Hello.java and compile it, the I move on to PartTwo.java but it compiles Hello.java again. Should I not use an IDE yet? (am using NetBeans) This is hard! Hand Model fucked around with this message at 23:32 on Jul 20, 2013 |
# ? Jul 20, 2013 23:25 |
|
Are you creating a new project for each problem? If not, it thinks the new file you've started is going to be called from some other file. In Netbeans you can right-click on the file and choose Run, as long as it has a public static void main method. It would probably be worthwhile teaching yourself how to compile and run java from the command line, as an IDE is probably overkill if you're just learning.
|
# ? Jul 20, 2013 23:45 |
|
|
# ? May 20, 2024 07:57 |
|
BlueJ is also a good IDE for beginners; I'd definitely recommend it over a command line, unless you're good at computers from some other source.
|
# ? Jul 20, 2013 23:49 |