|
I have a question that may have been asked, but from a general google search, I can't really find a good answer and trying to google this thread to find an answer isn't working well. I'm trying to distribute a program as runnable jar, to be used for Java Webstart. The issue that I am having is that m jar contains multiple other jars internally that it uses. The most common answer that I found was to simply repackage the jars, but I am weary of this due licensing issues. My current approach has been to try to move the files from inside of the jar, to another location outside of the jar and then use a class loader once they have been moved. I have been running into trouble trying to get them to move, so I was wondering if people had any advice on dealing with jars, or any suggestions on how to do this in a better way. EDIT: Ignore this, I managed to get it work The Glumslinger fucked around with this message at 23:39 on Jul 21, 2010 |
# ? Jul 20, 2010 23:53 |
|
|
# ? Jun 13, 2024 06:06 |
|
I'm really sorry for barging into a subforum I never participated in just to ask for help. I've been trying to work around this for days and Google isn't helping. I'm a complete newbie to Java who barely got started and I'm having trouble with what I feel is a trivial issue but it has stumped. Simply put, I want the String result of a Matcher search collapse the Unicode escape sequences, instead of presenting the whole String literally. For example, if I would simply use: code:
code:
code:
code:
code:
|
# ? Jul 21, 2010 01:40 |
|
YouAreCorrect posted:I have a question. Never met a recruiter or manager who cared about that cert but if my employer wanted me to get it and expected me to pay for it I would laugh in their face
|
# ? Jul 21, 2010 02:09 |
|
YouAreCorrect posted:This exam costs a poo poo load of , so I really want to pass it the first time. Wait they're asking you to foot the bill? Or you don't want to waste your company's money?
|
# ? Jul 21, 2010 03:14 |
|
epswing posted:Wait they're asking you to foot the bill? Well of course they will reimburse me. Just only when I pass.
|
# ? Jul 21, 2010 04:31 |
|
That's still a joke. You don't want to do this certification, why should you be $1,000 in the hole if you fail?
|
# ? Jul 21, 2010 06:44 |
|
Two Percent posted:I'm really sorry for barging into a subforum I never participated in just to ask for help. I've been trying to work around this for days and Google isn't helping. I'm a complete newbie to Java who barely got started and I'm having trouble with what I feel is a trivial issue but it has stumped. Those aren't unicode escape characters, they're octal escape characters. You convert them by finding the base10 representation and looking in the ASCII table, basically. This seems to do what you want, though it will require some modification to fit in with your stuff (since I couldn't really figure out what some of that code was doing). code:
code:
Kilson fucked around with this message at 09:15 on Jul 21, 2010 |
# ? Jul 21, 2010 09:10 |
|
Kilson posted:Those aren't unicode escape characters, they're octal escape characters. You convert them by finding the base10 representation and looking in the ASCII table, basically. Told you I'm a newbie... Yeah, I was trying to mean exactly what you said, I wanted them parsed to ASCII. Kilson posted:This seems to do what you want, though it will require some modification to fit in with your stuff (since I couldn't really figure out what some of that code was doing). And this worked perfectly. I just had to tweak it to accept more escape sequences like \t or \f and so on and it's working flawlessly. God bless you. Funny that replace("\\\\", "\\") works but replaceAll("\\\\", "\\") doesn't. Gotta pay more attention to the docs.
|
# ? Jul 21, 2010 21:07 |
|
Contra Duck posted:That's still a joke. You don't want to do this certification, why should you be $1,000 in the hole if you fail? Obviously you didn't work hard enough. From friends that took it, most of the tripping up for people comes from knowing some of the lesser used API's and gotchas along with poor wording. I've had two or three friends pass it, but they pretty much only studied for it, and were not working at the time.
|
# ? Jul 21, 2010 21:42 |
|
Two Percent posted:Told you I'm a newbie... To be honest, I had to look that up as well. It's not a terribly common construction. quote:Yeah, I was trying to mean exactly what you said, I wanted them parsed to ASCII. I think you can do replaceAll("\\\\\\\\", "\\") and it works the same way (yeah, it's stupid - gently caress you Java for not having a non-escaped regex syntax). I can't be 100% sure here, because this Linux machine I'm using seems to handle these characters strangely and outputs only characters that look like empty boxes, and won't allow me to copy/paste them here.
|
# ? Jul 21, 2010 22:28 |
|
Kilson posted:To be honest, I had to look that up as well. It's not a terribly common construction. It is a pain in the rear end. I've resorted to having a loader class which loads from POTF to make it easy. It also makes sense not to include regular expressions as part of the language since this isn't a language built around them. However, yes it does make them much more painful. I suppose you could have this get planted into the file with a shell / ant script during the build process. Maybe make a nice way to handle them in Eclipse through extension and second file? HFX fucked around with this message at 09:52 on Jul 22, 2010 |
# ? Jul 22, 2010 09:50 |
|
Has anyone ever had any success using the client's Windows credentials to login to a web application written in Java? I'm currently developing a Vaadin application and have been asked to investigate using said credentials in a single sign-on, but from what I've read around and about the internet it doesn't seem possible. Suggestions?
|
# ? Jul 22, 2010 12:13 |
|
bigfatspacko_uk posted:Has anyone ever had any success using the client's Windows credentials to login to a web application written in Java? I'm currently developing a Vaadin application and have been asked to investigate using said credentials in a single sign-on, but from what I've read around and about the internet it doesn't seem possible. java AppServers can do this with SPNEGO: http://www.ibm.com/developerworks/websphere/techjournal/0707_rogers/0707_rogers.html
|
# ? Jul 22, 2010 12:21 |
|
I have what's probably a really dumb question about unit testing and mocking. Is it possible to mock an object inside a class that doesn't have getters and setters? Right now I'm trying to write a unit test for a class that submits an XML feed to Amazon.com's marketplace web service. The problem is the class was designed to be totally self-contained. Normally all of our services are written with web service objects configured through Spring, so it's easy to pass a mock object in the unit test instead of directing it to the normal Spring configuration. In this case, the web service object is set up within the class I'm trying to test itself. We don't want to hit the actual service--just test that the code is working properly and is submitting the correct XML at the end of its process. Ideally, I could use a mock web service to "receive" the XML. What can I do here, aside from modifying the production code so that the web service object can be passed in? I hope this makes sense.
|
# ? Jul 22, 2010 19:25 |
|
Notorious H.P.B. posted:I have what's probably a really dumb question about unit testing and mocking. Is it possible to mock an object inside a class that doesn't have getters and setters? Right now I'm trying to write a unit test for a class that submits an XML feed to Amazon.com's marketplace web service. The problem is the class was designed to be totally self-contained. Normally all of our services are written with web service objects configured through Spring, so it's easy to pass a mock object in the unit test instead of directing it to the normal Spring configuration. In this case, the web service object is set up within the class I'm trying to test itself. We don't want to hit the actual service--just test that the code is working properly and is submitting the correct XML at the end of its process. Ideally, I could use a mock web service to "receive" the XML. What can I do here, aside from modifying the production code so that the web service object can be passed in? code:
zootm fucked around with this message at 21:26 on Jul 22, 2010 |
# ? Jul 22, 2010 21:15 |
|
Thanks! That's great to know in case I'm trying to test with these restrictions again. For now though, I got permission to modify the production code. This definitely seems like it will be useful, however. I can already think of a few test cases that this will make possible.
|
# ? Jul 22, 2010 23:59 |
|
I'm trying to make some changes to someone else's code written a few months ago that has since left the company. I am quite confused by his use of Class[] class.getClasses(). http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/lang/Class.html#getClasses%28%29 What exactly does this return? An array of the class and all of it's subclasses? Thanks for your help.
|
# ? Jul 23, 2010 13:52 |
|
sonic bed head posted:I'm trying to make some changes to someone else's code written a few months ago that has since left the company. I am quite confused by his use of Class[] class.getClasses(). As in classes defined within the class -- not the types/superclasses of the class itself. code:
|
# ? Jul 23, 2010 15:12 |
|
covener posted:As in classes defined within the class -- not the types/superclasses of the class itself. Ah! Got it. For some reason those two paragraphs in the docs were too confusing for me. Thank you.
|
# ? Jul 23, 2010 16:12 |
|
Notorious H.P.B. posted:I hope this makes sense. What zootm posted works sufficiently for testing (though I would always use Reflections as a last resort, in testing or production code). However, in future designs, getter/setter methods are good idea. If I want to maintain the immutability of an object's fields (i.e., no public getter/setters and no protected getter/setters to be used by a subclass of the given class), I make the setter method package-private - that way, the method is only exposed to classes within the same package (which includes the JUnit tests). Some might argue that it's still exposure because a programmer can make their package the same as your class' package, but the immutability of a class is still vulnerable as long as the Reflections API is allowed via security permission (which, if you're using Spring, I imagine it is).
|
# ? Jul 23, 2010 18:20 |
|
YouAreCorrect posted:Questions on SCJP exam. http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060/ref=sr_1_1?ie=UTF8&s=books&qid=1280013265&sr=8-1 That is the book to get for studying; it was written by the people that wrote the certification exam. There are pdf versions of it floating around also. I haven't taken the exam myself, but I haven't heard anyone say it was particularly difficult. Judging from the practice questions in that book, there is some "trickiness" for sure, but nothing that seems too bad. If you look hard enough you can also find some brain dumps/actual test questions. magnafides fucked around with this message at 00:26 on Jul 25, 2010 |
# ? Jul 25, 2010 00:22 |
|
Chairman Steve posted:What zootm posted works sufficiently for testing (though I would always use Reflections as a last resort, in testing or production code). However, in future designs, getter/setter methods are good idea. magnafides posted:http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060/ref=sr_1_1?ie=UTF8&s=books&qid=1280013265&sr=8-1 zootm fucked around with this message at 12:34 on Jul 26, 2010 |
# ? Jul 26, 2010 12:12 |
|
Carrying on the search, is there any Java equivalent of ASP's WindowsIdentity, or any libraries that emulate it? I need to get hold of the Windows token for a single sign-on solution in a Vaadin app, but am having merry hell finding a pure-Java solution. I'd really rather not have to use an ASP page first.
|
# ? Jul 26, 2010 15:31 |
|
Is there a way to remove all text from a Java Swing TextArea component? It seems like there should be, but on looking through the documentation I can't find a method to do so.
|
# ? Jul 26, 2010 15:46 |
|
fart factory posted:Is there a way to remove all text from a Java Swing TextArea component? It seems like there should be, but on looking through the documentation I can't find a method to do so. setText(""); ?
|
# ? Jul 26, 2010 15:57 |
|
zootm posted:For what it's worth I find getters/setters a bad paradigm as they make it impractical or impossible to use the language's built-in features for enforcing some degree of immutability, but constructor injection is definitely worthwhile. Definitely. I like constructor injection because it ensures that all dependencies are accounted for (assuming proper constructor...er...construction). My personal preference is to write an interface with only getters (no setters) and implement it with an object that has setters - effectively, the consumer has no idea about the setters and sees only the interface, but I'm still able to override and inject for testing. I probably should have mentioned that in my original post. Oh, interfaces.
|
# ? Jul 27, 2010 04:10 |
|
csammis posted:setText(""); ?
|
# ? Jul 27, 2010 08:26 |
|
Chairman Steve posted:Definitely. I like constructor injection because it ensures that all dependencies are accounted for (assuming proper constructor...er...construction). My personal preference is to write an interface with only getters (no setters) and implement it with an object that has setters - effectively, the consumer has no idea about the setters and sees only the interface, but I'm still able to override and inject for testing. I probably should have mentioned that in my original post.
|
# ? Jul 27, 2010 15:58 |
|
Chairman Steve posted:Definitely. I like constructor injection because it ensures that all dependencies are accounted for (assuming proper constructor...er...construction). My personal preference is to write an interface with only getters (no setters) and implement it with an object that has setters - effectively, the consumer has no idea about the setters and sees only the interface, but I'm still able to override and inject for testing. I probably should have mentioned that in my original post. Do you name everything IFoo and/or FooImpl? That's the part of that paradigm that I hate.
|
# ? Jul 27, 2010 16:50 |
|
TRex EaterofCars posted:Do you name everything IFoo and/or FooImpl? That's the part of that paradigm that I hate. In Java, I totally agree with you. IFoo is the language convention in C# though, so it's easy to see how you could slip into that naming scheme on autopilot.
|
# ? Jul 27, 2010 17:02 |
|
Internet Janitor posted:In Java, I totally agree with you. IFoo is the language convention in C# though, so it's easy to see how you could slip into that naming scheme on autopilot. There isn't convention for this which causes people to use at least these three depending on how bad the coffee was the morning they started programming: Interface starts with I (ICarAnalogy), class name as normal. (CarAnalogy) Quite straight forward, nothing special about it. Interface is named normally(CarAnalogy), implementation is appended with Impl(CarAnalogyImpl). This, in my opinion, is the ugliest convention. Looks especially horrible if you use common clutter words such as Factory, Processor or Service. Interface denotes general level of applicability(CarAnalogy), class name denotes specific part of specialized implementation(WhatCarIsToCarpetAnalogy). As you can see from the example, it's very explicit which is good but it will also easily cause quite lengthy and thus horrible class names very easily. Within Java API there isn't any hierarchies with IInterfaces but the other two can be found easily. If I had the power, I'd enforce the usage of the third option though, since it forces the programmer to think about class names for just a bit longer and usually if you can't find a good name for whatever you're doing, then you most likely have an issue with your whole architecture in that specific point of the domain model.
|
# ? Jul 27, 2010 17:24 |
|
Parantumaton posted:There isn't convention for this which causes people to use at least these three depending on how bad the coffee was the morning they started programming: I agree, I tend to prefer the third method so that I am forced to sit there and think about what I'm doing. It's definitely caused me to rethink my strategy a number of times.
|
# ? Jul 27, 2010 18:11 |
|
TRex EaterofCars posted:Do you name everything IFoo and/or FooImpl? That's the part of that paradigm that I hate. I go the route of naming the interface the noun or adjective it represents ("Car" or "Driveable"), which satisfies the "is/isa" kind of relationship that an interface is supposed to be in Java. I used to do the *Impl pattern, but I've moved to the following:
[ Edit: I hate the ICar naming convention. It violates the nature of interfaces, in my opinion - you don't go around naming your classes "CCar" or "CDriveable", do you? ]
|
# ? Jul 28, 2010 00:44 |
|
Parantumaton posted:There isn't convention for this which causes people to use at least these three depending on how bad the coffee was the morning they started programming: Bad programmer, no biscuit! Hungarian notation is terrible unless you program exclusively in notepad.
|
# ? Jul 28, 2010 03:26 |
|
Okay so after reading about the util.concurrent package for a day or two and playing around with it. I have grown pretty fond of how well it works, with regards to locks and synchronization. However i still have not really found any concrete example/reasoning behind "Why" was it needed. As opposed to using the synchronized keyword? I understand it scales better, but alot of the articles mention something along the lines of: "java.util.concurrent resolves several long standing issues with java threading" However nothing really follows up with explain exactly what problems it solves.
|
# ? Jul 28, 2010 15:23 |
|
UberJumper posted:Okay so after reading about the util.concurrent package for a day or two and playing around with it. I have grown pretty fond of how well it works, with regards to locks and synchronization. However i still have not really found any concrete example/reasoning behind "Why" was it needed. As opposed to using the synchronized keyword? I understand it scales better, but alot of the articles mention something along the lines of: "java.util.concurrent resolves several long standing issues with java threading" However nothing really follows up with explain exactly what problems it solves. The point of java.util.concurrent is that it does all the common (and some not-so-common) tasks for you with guaranteed non-breaking functionality while you can just go and code away whatever you're doing. Sure, writing your own ExecutorService isn't hard (or it may at least seem like so) but when you look at FutureTask and realize that all YOU need to do is to implement Callable and the actual task you want to perform and you still get all the possible things Executors allow you to do and pausing, canceling etc. provided by FutureTask with guaranteed behavior out of the box, you should just look smug and be happy that some people spent a lot of time so that you wouldn't have to. As minor trivia, java.util.concurrent is the base package for multiple other JVM languages which deal with concurrency. These languages include at least Clojure and Scala which bot actually just wrap Executors for most of the concurrent structures they have.
|
# ? Jul 28, 2010 16:19 |
How come something like this works:code:
code:
|
|
# ? Jul 30, 2010 18:57 |
|
No good reason. You can use array-literal syntax, though: new String[]{ "stuff" }.
|
# ? Jul 30, 2010 19:07 |
|
rjmccall posted:No good reason. You can use array-literal syntax, though: new String[]{ "stuff" }. The reason is (most likely) that code:
|
# ? Jul 30, 2010 20:58 |
|
|
# ? Jun 13, 2024 06:06 |
|
Parantumaton posted:The point of java.util.concurrent is that it does all the common (and some not-so-common) tasks for you with guaranteed non-breaking functionality while you can just go and code away whatever you're doing. Sure, writing your own ExecutorService isn't hard (or it may at least seem like so) but when you look at FutureTask and realize that all YOU need to do is to implement Callable and the actual task you want to perform and you still get all the possible things Executors allow you to do and pausing, canceling etc. provided by FutureTask with guaranteed behavior out of the box, you should just look smug and be happy that some people spent a lot of time so that you wouldn't have to.
|
# ? Jul 31, 2010 05:52 |