|
Yeah, you shouldn't ever compare Strings using ==. Always use String.equals() or you'll get behavior like you're seeing.
|
# ? Mar 5, 2017 06:57 |
|
|
# ? Jun 3, 2024 07:40 |
|
Yep, that fixed it instantly. Thanks for the help!
|
# ? Mar 5, 2017 07:55 |
|
What's the correct way to include .jar libraries in deploys for JBoss? I've done it a couple of different ways. Thrown it into JBoss' lib folder, in the project's lib folder, in the MANIFEST.MF file, in the ant build file.
|
# ? Mar 14, 2017 12:36 |
|
Use Maven and don't think about it?
|
# ? Mar 14, 2017 13:01 |
|
if it's not in some maven repository, don't use it.
|
# ? Mar 14, 2017 14:40 |
|
BabyFur Denny posted:if it's not in some maven repository, don't use it. I don't agree with this at all. There are some libraries that are hosted in Maven Central that have, for lack of better term, "add-on" libraries that are not in Maven Central that you have to download individually (Why IBM? Why?) or you might have a very old library that still has a need in your application and you can't find a suitable replacement or just can't do a refactor at the moment. So instead, use Artifactory and upload it to your own Maven repository.
|
# ? Mar 14, 2017 23:50 |
|
I'm new to Java and I'm having a problem that nobody else seems to have, or at least, not that google can find. See, when using String.format, if you want to print a literal % in your string, you escape it with another %. So, if you wanted to print a formatted string that looks like this:quote:This is a percent sign: % You would write this code: code:
code:
code:
|
# ? Mar 14, 2017 23:54 |
System.out.printf is special, it has the formatting stuff built in, so you're probably end up doing it twice. Try playing around with System.out.println instead.
|
|
# ? Mar 15, 2017 00:01 |
|
Aren't you essentially calling format twice? efb
|
# ? Mar 15, 2017 00:04 |
|
Yeah the f is for format (or formatted or whatever). You're basically stripping out the escape % with the first format call
|
# ? Mar 15, 2017 00:12 |
|
Ah! That makes sense. Thanks so much, that's been bugging me for weeks.
|
# ? Mar 15, 2017 00:16 |
|
geeves posted:I don't agree with this at all. There are some libraries that are hosted in Maven Central that have, for lack of better term, "add-on" libraries that are not in Maven Central that you have to download individually (Why IBM? Why?) or you might have a very old library that still has a need in your application and you can't find a suitable replacement or just can't do a refactor at the moment. Yup. Pretty much any artifact that is under one of Sun's packages, or javax.*, and is NOT an API-only jar, is not going to be available in the Maven-Central repo. Sun/Oracle's license is pretty horrendous and so they get shut out of OSS repositories. Same problem that afflicts Oracle JDK in the official distributions. The place where this usually bites you is stuff like the Oracle OJDBC driver, or some of the javax artifacts like jdbc-stdext. For the most part, web stuff will be bundled and/or injected with your web server so at least that's not a real problem - you just need to note it as "provided" in your pom.xml. In theory you should be able to point Maven at a "local repository" across file:// too - however I haven't been able to make this work reliably. It works for my local PC (probably gets installed into my .m2) but not on other computers. Also, Maven's caching rules are a cast-iron bitch for trying to debug this and I haven't figured out a viable way around them short of deleting the whole .m2 folder and letting it re-resolve everything. Gradle, on the other hand, works perfectly in this use-case. It understands the concept of a Maven repository on disk, or you can just give it a "libs" directory full of jars to include like you would with an Ant build. As such I think that probably makes it an easier sell for teams converting from legacy Ant build scripts and/or working offline. This is kind of unfortunate since in theory I like the idea of a Maven build much better. The declarative model is very easy for IDEs to handle for setting up classpath, and unlike Gradle you don't need a "build daemon" hanging around to get decent performance. But apart from the "imperative" style format and the daemon - I think they really get you to pretty much the same place. And gradle gives you a better mix for transitioning legacy code - you can write pretty much the same stuff as you would in Ant, but you benefit from the dependency resolution and modern conventions of Maven.
|
# ? Mar 15, 2017 01:32 |
|
Your legal department probably doesn't want you to use that weird Sun junk anyways.
|
# ? Mar 15, 2017 03:04 |
|
smackfu posted:Your legal department probably doesn't want you to use that weird Sun junk anyways. I personally stay the hell away from it, if for no other reason than because since it's not in the main repos it doesn't get automatic updates. Still though, you might be surprised. The ToS from Oracle are a known quantity, and lots of project managers prefer the devil you know over "software from some guy on the internet" and "regular security updates" and similar forms of heresy. Again, given that the client is using Oracle DB anyway, we're kind of in for a penny anyway, but at least that's mostly on them, they made that deal with the devil themselves. Personally I'd go with Postgres over literally anything else any day, unless my workload literally couldn't be serviced by a decked-out 8-socket Xeon server. So far it doesn't have good support for horizontal scaling/distributed transactions - but anything short of that it works fine. Honestly OJDBC has been one parade of bugs after another. Today, Hibernate decided to revert to the default sequence for no actual reason that we can determine - but only on the "sequence" generator type, the deprecated "sequence-identity" generator type works fine. Paul MaudDib fucked around with this message at 03:47 on Mar 15, 2017 |
# ? Mar 15, 2017 03:44 |
|
geeves posted:I don't agree with this at all. There are some libraries that are hosted in Maven Central that have, for lack of better term, "add-on" libraries that are not in Maven Central that you have to download individually (Why IBM? Why?) or you might have a very old library that still has a need in your application and you can't find a suitable replacement or just can't do a refactor at the moment. If it is in your artifactory then it is in a maven repository and it's fine. So we actually don't disagree.
|
# ? Mar 15, 2017 07:29 |
|
BabyFur Denny posted:If it is in your artifactory then it is in a maven repository and it's fine. So we actually don't disagree. True
|
# ? Mar 15, 2017 15:48 |
|
I'm using a few libraries which depend on different versions of Guava. A few use an older version of Guava and when I try to do something with the jar I'm building (Spark-submit it) it's giving me a NoSuchMethod error. That method is missing in Guava before 15. I assume that the class loader is loading an older version for some reason, even though Gradle's dependency tree shows everything being forced to the latest version. Is there a way for me to handle this? I did something similar with shading but I can't see to figure this out.
|
# ? Mar 16, 2017 22:30 |
|
I'd like to start up a personal project to learn more about the Java EE world, but I've never been good at coming up with something myself. I thought about making a web service that will tell you if Netflix has a given title and then possibly expanding that to include an Android app which would let you use the Google Assistant, but it looks like Netflix ended that API some time ago, so that might not be feasible. Where can I go to get ideas for this sort of project?
|
# ? Mar 17, 2017 01:42 |
|
Good Will Hrunting posted:I'm using a few libraries which depend on different versions of Guava. A few use an older version of Guava and when I try to do something with the jar I'm building (Spark-submit it) it's giving me a NoSuchMethod error. That method is missing in Guava before 15. I assume that the class loader is loading an older version for some reason, even though Gradle's dependency tree shows everything being forced to the latest version. Have you excluded the dependencies from the library that might be responsible in your gradle.build file? (I just went through this process with Maven, it's a pain in the rear end.)
|
# ? Mar 17, 2017 03:50 |
|
geeves posted:Have you excluded the dependencies from the library that might be responsible in your gradle.build file? (I just went through this process with Maven, it's a pain in the rear end.) Our last resort is excluding all pre-14 (or 15) Guava transitive dependencies from all of the dependencies that pull it in and just leave the ones with post-problematic Guava. I'm not sure how Gradle works but I assume that it won't even download them or add them to the classpath if I do this exclusion, right? (Disclaimer: This is my first job using Gradle and I've used it for 2 weeks, before that I used Maven)
|
# ? Mar 17, 2017 04:15 |
|
Good Will Hrunting posted:I'm using a few libraries which depend on different versions of Guava. A few use an older version of Guava and when I try to do something with the jar I'm building (Spark-submit it) it's giving me a NoSuchMethod error. That method is missing in Guava before 15. I assume that the class loader is loading an older version for some reason, even though Gradle's dependency tree shows everything being forced to the latest version. This is not gradle-specific, and it's pretty much always one of two problems. You either have an API jar and no implementation, or you have two copies of this hanging out somewhere in your dependencies. Look again.
|
# ? Mar 17, 2017 04:23 |
|
Paul MaudDib posted:two copies of this hanging out somewhere in your dependencies What do you mean by this? The problematic Guava version is being provided somewhere other than dependency resolution?
|
# ? Mar 17, 2017 05:10 |
|
Good Will Hrunting posted:What do you mean by this? The problematic Guava version is being provided somewhere other than dependency resolution? Maybe not that version, but you have two versions coming from somewhere. Maybe try building a jar-with-dependencies and see if there's two copies in there? Maybe there's another copy in a far-jar that is outside dependency resolution?
|
# ? Mar 17, 2017 06:50 |
|
Ask, the libraries that rely on older versions of the dependencies might not even work properly with the new one, even if you get it set to only use the new one. So that's fun.
|
# ? Mar 17, 2017 13:06 |
|
Paul MaudDib posted:Maybe not that version, but you have two versions coming from somewhere. Maybe try building a jar-with-dependencies and see if there's two copies in there? Maybe there's another copy in a far-jar that is outside dependency resolution? So I built the jar with dependencies - am I looking for multiple copies of the class in the results of jar tf?
|
# ? Mar 17, 2017 15:07 |
|
Found it by adding -verbose:class to spark-submit to show where the classes were being loaded from. Inside the Spark download there's a jars director with an old version of Guava.
|
# ? Mar 17, 2017 17:05 |
|
When working with tasks that query external services (and thus block the thread on a thread pool/executor service), do you guys use anything to provide Green Threads or similar functionality? Anything that doesn't require using JVM agents, like Quasar does? I'm dealing with something where a single request can issue multiple tasks which are submitted to an executor service, where each task has to query an external service (with some timeout) blocking the thread. I'm kinda paranoid that the slowdown on the external service would exhaust the parent thread pool, so i'm looking for better alternatives.
|
# ? Mar 19, 2017 19:01 |
|
Take a look at Dagger Producers, and see if that sounds promising for you.
|
# ? Mar 19, 2017 20:15 |
|
What's the best way to avoid dependency conflicts when dealing with libraries that are only offered via fat JAR? Spark just ships with so many old dependencies that are giving me a massive headache when trying to work with multiple other necessary libraries.
|
# ? Mar 20, 2017 13:53 |
|
Good Will Hrunting posted:What's the best way to avoid dependency conflicts when dealing with libraries that are only offered via fat JAR? Spark just ships with so many old dependencies that are giving me a massive headache when trying to work with multiple other necessary libraries. Spark is in Maven Central un-bundled, unless that's a different artifact? In general the solutions to this problem are shading (rewrite bytecode so your conflicting dependencies have unique package names) or OSGi (run each dependency in its own classloader).
|
# ? Mar 20, 2017 16:05 |
|
Sedro posted:Spark is in Maven Central un-bundled, unless that's a different artifact? To submit Spark apps (at least via spark-submit which I'm trying to use right now) you have to package all of your necessary JARs (including all dependencies of Spark) together in a fat JAR for submission so I don't think the un-bundled version will help too much unfortunately. The issue I'm having is that my app needs, for example, library A version 2.0 which depends on library B version 2.0 whereas Spark's bundle comes with and depends on library B version 1.5. Cross-versioning is causing issues on both sides, both older and newer. I need to look into shading to see if this is a problem that can be solved by it but I'm not sure how it would work with the transitive dependencies.
|
# ? Mar 20, 2017 16:52 |
|
If you're building the fat jar yourself with maven-assembly-plugin or similar, it should include version 2.0 and not version 1.5. Things get nasty though if the two versions are not compatible.
|
# ? Mar 20, 2017 17:14 |
|
One of the many reasons why spark is such a terribly lovely framework
|
# ? Mar 20, 2017 20:10 |
|
BabyFur Denny posted:One of the many reasons why spark is such a terribly lovely framework This is the first I've used it outside of Databricks managed service for processing 200,000,000 line flat files from third party data sources and batch writing them to a database, which it ruled for doing easily. Doing this poo poo sucks so far.
|
# ? Mar 20, 2017 20:26 |
|
Best book, or way to learn Java for someone who hasn't touched it since applets and Java 2?
|
# ? Mar 20, 2017 20:54 |
|
Bob Morales posted:Best book, or way to learn Java for someone who hasn't touched it since applets and Java 2? Effective Java Java 8 Lambdas Functional Programming for the Masses Edit: correct title. geeves fucked around with this message at 00:43 on Mar 21, 2017 |
# ? Mar 21, 2017 00:07 |
|
On that same line of thinking, does anyone have a course or program they could recommend for learning web services? I really need to bite the bullet and get my head around it to get some reporting tools on our intranet. I had a coworker make a mockup Spring example for me but I really learn by doing so a class over just a book or site would be preferred.
|
# ? Mar 21, 2017 00:23 |
|
What do you mean web services? That's pretty broad! What are you trying to do?
|
# ? Mar 21, 2017 00:37 |
|
Good Will Hrunting posted:What do you mean web services? That's pretty broad! What are you trying to do? Ultimately I'd like to publish reports from a tool with an API to a site so users can query for live results. I have a basic Swing GUI with all the proper reports and results, but they want a web interface instead of an executable. I don't particularly mind as I'd like to learn this angle of things anyway. The reports are just plaintext information, so the data in question is simple, I just need to publish it with a method to query based on string search values.
|
# ? Mar 21, 2017 01:04 |
|
|
# ? Jun 3, 2024 07:40 |
|
PierreTheMime posted:Ultimately I'd like to publish reports from a tool with an API to a site so users can query for live results. I have a basic Swing GUI with all the proper reports and results, but they want a web interface instead of an executable. I don't particularly mind as I'd like to learn this angle of things anyway. Look into Jersey https://jersey.java.net or Spring Boot with REST https://spring.io/guides/gs/rest-service/ (We use the former in production and for a brand new API looking into the latter.
|
# ? Mar 21, 2017 01:20 |