|
oh no computer posted:Yeah I'm not trying to make games only getting some general practice in with GUI stuff. It's complicated. JavaFX is much more modern and nicer to use than Swing, but it was only a part of the base JDK for a few releases before it was pulled out again. Meaning now you need to include the JavaFX modules and ship separate versions of your applications for each OS if you want to be compatible with Java 11. This leaves Swing as the there-by-default always-looks-the-same UI toolkit for Java, so even though it basically hasn't changed in decades there's still value if "write once run anywhere" is your primary goal.
|
# ? Feb 21, 2019 18:25 |
|
|
# ? May 9, 2024 03:16 |
|
I feel like a lot of apps have just switched to running local web servers if they need a UI.
|
# ? Feb 25, 2019 14:00 |
|
carry on then posted:It's complicated. JavaFX is much more modern and nicer to use than Swing, but it was only a part of the base JDK for a few releases before it was pulled out again. Meaning now you need to include the JavaFX modules and ship separate versions of your applications for each OS if you want to be compatible with Java 11. This leaves Swing as the there-by-default always-looks-the-same UI toolkit for Java, so even though it basically hasn't changed in decades there's still value if "write once run anywhere" is your primary goal. But you need to do that anyway now with java 11. People are no longer supposed to install a JRE and just run your app (fat jar or however you bundled it) . You make a package for a particular OS that includes the modules that your application uses and the jre and that's that. That's my understanding anyway, I haven't got there yet. I'm still on Java 8 at work and at home i haven't bothered in the last 10 years to write a java app.
|
# ? Feb 25, 2019 15:01 |
|
Volguus posted:But you need to do that anyway now with java 11. People are no longer supposed to install a JRE and just run your app (fat jar or however you bundled it) . You make a package for a particular OS that includes the modules that your application uses and the jre and that's that. That's my understanding anyway, I haven't got there yet. I'm still on Java 8 at work and at home i haven't bothered in the last 10 years to write a java app. A fat jar for a Swing app is still one jar for everyone. All the projects I've seen that use JavaFX 11 have separate executables per platform generated using jlink. The forthcoming rerelease of javapackager with Java 12 will move more in that direction. There's also a lot of hesitation to even require Java 11, which for JavaFX then means you *need* to require Java 8 in order to ensure that the requisite libraries are present. I haven't seen a convincing solution so ship one JavaFX application jar that works on both 8 and 11, but Swing does it the same way it always has. e: I guess my point is, the JavaFX story is complicated enough that for smaller applications it becomes tempting to avoid all of it even if the resulting UI will be worse, because sadly user experience seems to take a back seat to just about everything nowadays. carry on then fucked around with this message at 16:56 on Feb 25, 2019 |
# ? Feb 25, 2019 16:36 |
|
The idea is that you don't require anything from the user anymore. When you package your application with jlink you include the JRE as well. The user doesn't have to have anything installed anymore, he/she gets the entire package from the developer. It's a bit more of a headache to setup for the first time, but after that it "just works". Of course, the other downside is that the user may have 100 JREs installed , like they have 100 electron engines installed. Oh well, space is cheap (or so they think) so ... yea.
|
# ? Feb 25, 2019 17:00 |
|
Are there any examples of jlink actually working usefully for non-trivial projects? Every time I’ve looked at it I’ve realised just how many of my dependencies are not modules and probably never will be modules unless I fork them and do all the work myself, and it looks like jlink is basically useless in that case as it will have no idea which modules it needs to include. Javafx moving out of the jdk is great though, because it goes back on the class path instead of the module path so java stops complaining about all our lovely reflection hacks Soricidus fucked around with this message at 01:16 on Feb 26, 2019 |
# ? Feb 26, 2019 01:14 |
|
Anyone have any recommendations for a resource on learning Java if you already have a decent amount of C# experience? Looks like I might accept a position soon () and it's mainly Java focused, which I've only barely dabbled in, but I know it's incredibly similar to C#.
|
# ? Feb 26, 2019 17:59 |
|
Speaking of libgdx and stuff, ive recently upgraded to lwjgl3 backend. That requires '-XstartOnFirstThread' flag. That for whatever reason breaks awt/swing. The only reason i care about that, is that id like to replace the dock icon with something sensible. Previously ive used 'com.apple.eawt.Application' set dock stuff, also tried '-Xdock' flag and Taskbar in jdk9+. None of that worked. Anyone knows if there is a way to set the dock icon some other way, that doesnt involve bundling the app?
|
# ? Feb 26, 2019 21:19 |
|
The Dark Wind posted:Anyone have any recommendations for a resource on learning Java if you already have a decent amount of C# experience? Looks like I might accept a position soon () and it's mainly Java focused, which I've only barely dabbled in, but I know it's incredibly similar to C#. Dude, you're solid. If anything, maybe just brush up on how the standards are different (ClassImpl instead of IClass), camelcase everything, open braces on same line, etc etc. I went from Java to C# doing hobby game dev and it was no effort whatsoever.
|
# ? Feb 26, 2019 23:00 |
poemdexter posted:Dude, you're solid. If anything, maybe just brush up on how the standards are different (ClassImpl instead of IClass), camelcase everything, open braces on same line, etc etc. The only other thing I was gonna mention was brushing up on available tooling (i.e. build, code coverage, IDE, profiling / monitoring tools, unit testing)
|
|
# ? Feb 26, 2019 23:39 |
|
I'm working in my first development job out of university on a legacy back-end Java product in the UK. Over the past few months I've been getting increasingly triggered by various aspects of the code base, such as:
There's opportunity to move teams and I'm intending to talk to management about a move to a newer product with modern architecture and technologies. But I'd value some perspective on how I'm feeling and to what extent I should suck it up / get over it / buckle up for the long haul. Is this the norm for enterprise Java? How rare are companies/teams that get this stuff right? Should I be shooting for Big N and higher-tier companies if this is important to me?
|
# ? Mar 10, 2019 15:19 |
|
I've been doing dev for a long time at a lot of companies from Fortune 100 down to a small <10 person company. You're going to run into most of those problems at any company and it will vary from project to project. I'm sure that there are companies that do it much better than others but they're rare and you likely won't know for sure until your hired and working on a project.
|
# ? Mar 10, 2019 16:37 |
|
Daviclond posted:There's opportunity to move teams and I'm intending to talk to management about a move to a newer product with modern architecture and technologies. But I'd value some perspective on how I'm feeling and to what extent I should suck it up / get over it / buckle up for the long haul. Is this the norm for enterprise Java? How rare are companies/teams that get this stuff right? Should I be shooting for Big N and higher-tier companies if this is important to me? Your list is common in a place with an older application, many mediocre developers and management that cares more about short term features than future delays and techdebt. You should never buckle up if you are unhappy, life is just to short for that. This horseshit is however found in a lot of places, mostly those that pay not so much and thus attract mediocre lifers. Companies that get this right are rare but you can guess their names.
|
# ? Mar 10, 2019 16:39 |
|
Daviclond posted:There's opportunity to move teams and I'm intending to talk to management about a move to a newer product with modern architecture and technologies. But I'd value some perspective on how I'm feeling and to what extent I should suck it up / get over it / buckle up for the long haul. Is this the norm for enterprise Java? How rare are companies/teams that get this stuff right? Should I be shooting for Big N and higher-tier companies if this is important to me? In my experience everything you said is the norm when you're maintaining a legacy project. It has probably changed hands at least 5 times and none of the original devs work in the company anymore. For some reason the version control contains meeting minutes and vacation requests from 2008. The project wiki contains a lessons-learned section from 2012 that lists things that are still a problem. If you want to start refactoring the code, I recommend using http://pitest.org/ for testing your code coverage.
|
# ? Mar 11, 2019 07:50 |
|
I don't have a technical question, just a request for recommendations. I learned basic Java way back in high school: methods, classes, objects. Since then, I've used it professionally and in my hobby projects effectively and encountered no issues. But now, my projects have gotten more complex and I've run into examples on Stack Overflow and even Oracle's Javadocs that seem completely foreign to me. They've hinted at features that I've only heard of in other languages: lambda functions, properties, list comprehension, etc. I'm familiar with these in other languages, but I didn't know they were available in Java and so never learned them there. What's a good resource for learning "modern" Java for someone who's familiar with the language and these features in other languages? Part of the problem is that I don't know what I don't know, and so I can't just search for "X in Java". Thanks in advance.
|
# ? Apr 3, 2019 16:47 |
|
If properties and list comprehensions are in Java now, that's news to me, but I've been out of the Java world for two years now. Looking at the Java version history article on Wikipedia, the big syntax features you might not know yet are lambdas and var, while the big library features are Streams and maybe java.time. Edit: Oh, also modules, but I have zero experience with those.
|
# ? Apr 3, 2019 17:18 |
|
NuclearEagleFox!!! posted:I don't have a technical question, just a request for recommendations. https://www.baeldung.com/ is a pretty good resource.
|
# ? Apr 3, 2019 17:36 |
|
RandomBlue posted:https://www.baeldung.com/ is a pretty good resource. Thanks, this is pretty much exactly what I was looking for!
|
# ? Apr 4, 2019 15:49 |
|
I've just started to play with Java for the first time since university back in 2004. I decided to flick through this thread from the beginning and it's helping. I got to a post back in 2009 with someone's homework assignment and decided to make it. Here is my effort. Two questions. 1) General feedback on my way of doing it? 2) How does an inner class work? I was trying to create another object of GradeInformation which would be inited with a constructor of say ("A", 90, 100). Then I could have an array of GradeInformation objects, and iterate through it to init things instead of hardcoding it. That data could then for example be read in from a file too. When I was trying to run GradeInformation() it was saying something about "Method call expected". Java code:
Sad Panda fucked around with this message at 23:13 on Apr 8, 2019 |
# ? Apr 8, 2019 23:11 |
|
You're going to pick up a lot of outdated info and broken links reading Java posts from 10 years ago. I wouldn't recommend you approach it that way.
|
# ? Apr 9, 2019 01:19 |
|
Sad Panda posted:I've just started to play with Java for the first time since university back in 2004. I decided to flick through this thread from the beginning and it's helping. I got to a post back in 2009 with someone's homework assignment and decided to make it. Your approach is... Consistent with what I'd expect from someone looking at resources and homework assignments from a decade+ ago. It's not awful, but it's not modern Java. I'm not really sure where to point you here for an intro to modern Java aimed at someone newish to programming. But this is a good start overall! It's good that you factored updateMarkBook out into its own method rather than doing it directly in getInput for example. Here's what I'd recommend:
I'd also recommend looking up Java Streams at some point, but that might be a bit past where you are right now. Regarding inner classes, you almost never want a non-static inner class - non-static inner classes are some weirdass poo poo that I've never seen anywhere other than example code for explaining how they work. Use a static inner class (technically a "nested class") instead - just use "static class GradeInformation" instead of just "class GradeInformation" and you should have fewer problems. I'm not sure how to answer your specific question as I don't quite understand what you were trying to do and what problems you were running into.
|
# ? Apr 9, 2019 03:04 |
|
Speaking of learning newer Java options, can anyone tell me what I'm doing wrong with this? I've got a simple class with a Date variable and I'm compiling a List of objects from that class, but I cannot seem to be able to sort them as expected based on the Date value.code:
|
# ? Apr 9, 2019 15:43 |
|
That's weird. It's simple enough and certainly looks like it should work. I suspect your problem isn't on that line.Arcsech posted:Regarding inner classes, you almost never want a non-static inner class - non-static inner classes are some weirdass poo poo that I've never seen anywhere other than example code for explaining how they work. Remember that all lambdas and anonymous objects are just instances of anonymous inner classes. Named inner classes are less common these days but fundamentally no different.
|
# ? Apr 9, 2019 16:22 |
|
Sindai posted:Java's annoying one public root element per source file limitation. Fixed, because while the limitation is still annoying and stupid, it's that special, unique kind of stupid that Java's so good at!
|
# ? Apr 9, 2019 16:36 |
|
Sindai posted:That's weird. It's simple enough and certainly looks like it should work. I suspect your problem isn't on that line. Yeah, I figured it out, the object being evaluated was from a different source, the sort works fine. I don't get to use many "new" features super often, but this is certainly one I appreciate.
|
# ? Apr 9, 2019 16:47 |
|
Sindai posted:Remember that all lambdas and anonymous objects are just instances of anonymous inner classes. Saying that a lambda is just an instance of an anonymous inner class is oversimplifying things by quite a bit. Here is a talk by Brian Goetz that goes into some detail: https://www.youtube.com/watch?v=MLksirK9nnE
|
# ? Apr 9, 2019 17:11 |
|
Totally gonna watch that on company time under the guise of "research," even though I already know about lambdas and have used them a bunch!
|
# ? Apr 9, 2019 17:23 |
|
Sindai posted:That's interesting, I would have said the opposite - dynamic inner classes are far more common and useful since they have a useful semantic feature (a reference to the outer object) while static inner classes are just an organizational tool to make up for Java's annoying one root element per source file limitation. That last bit is true (sorta, as has already been mentioned), but I was referring to named inner classes. And I was exaggerating, I have seen them used, but very rarely and they are pretty counterintuitive unless you understand how they work at a level deeper than most beginners are prepared for.
|
# ? Apr 9, 2019 18:41 |
|
Sad Panda posted:Two questions. An inner class is basically just a class, but because it's located inside another class it gives you some organisational options. If you leave it visible from outside the outer class, then other stuff can use it, but only through an instance of that outer class - so they're inherently connected, like the inner class is some aspect of the outer, which makes it clearer how your project is structured and what relates to what. If you make the inner class private, only the outer class can use it, so that functions more as an internal helper class that your outer one makes use of - which is what you wanted to do. That way this internal implementation detail doesn't leak out and cause confusion, or problems if you ever want to change it The other thing about inner classes is they can see all the outer class's private stuff, which means you can take the OOP approach to your problem without having to expose parts of your main outer class just so the other classes you've come up with can interact with the methods and fields they need. By making them internal inner classes, you don't have to worry about visibility - it's all nicely encapsulated. (This isn't the only way to deal with this kind of thing, but it's how inner classes work anyway) as for yr code, if the grades were hardcoded I'd suggest using an enum instead of rolling your own class, but yeah if that grade scheme needs to be separately provided then you'd need your own class (enums are like a class with a fixed set of instances that are initialised when your program starts). Personally I'd probably make a Grade class (name, lower bound, upper bound) and a MarkBook class (constructor takes a bunch of Grades as a Collection or vararg or whatever, creates a map of Grades to counts initialised at zero). That way you just need to
that way you've broken it up into a basic flow - you have some input bits, you have a couple of ways you want to parse those inputs, you end up with your data (Grades and scores), and then you just feed that data to the MarkBook which is really the business end of things, everything else is more like prep work, y'know? oh as well as what other people mentioned, this Java code:
Java code:
(also you can drop the generic types in the instantiation and just use the diamond operator, HashMap<>, because your declaration already specified them - get an IDE it'll tell you this stuff and fix it for ya) baka kaba fucked around with this message at 20:14 on Apr 9, 2019 |
# ? Apr 9, 2019 20:07 |
|
ivantod posted:Saying that a lambda is just an instance of an anonymous inner class is oversimplifying things by quite a bit. Unrelated, but this video on a different topic briefly touches on lambdas vs closures. In any case, it's really worth a watch. https://www.youtube.com/watch?v=DOoJnJJnAG4
|
# ? Apr 10, 2019 11:49 |
|
Edit: nevermind, worked it out
oh no computer fucked around with this message at 13:51 on Apr 10, 2019 |
# ? Apr 10, 2019 13:48 |
|
When did File start accepting normal Windows-based pathing without format changes? Being able to just pass the argument via copy/paste without formatting is a pleasant surprise. I don't get to work with "real" programming languages enough.
|
# ? Apr 10, 2019 16:53 |
|
PierreTheMime posted:When did File start accepting normal Windows-based pathing without format changes? Being able to just pass the argument via copy/paste without formatting is a pleasant surprise. I don't get to work with "real" programming languages enough. I did not know about File, but Path has been capable of that since Java 7 if i'm not mistaken. https://docs.oracle.com/javase/tutorial/essential/io/pathOps.html
|
# ? Apr 10, 2019 17:00 |
|
I'm trying to get back into Java for practice while I look for a coding job. I took a Java class years ago in university, but my school mostly focused on C++. There are a lot of jokes/half jokes about Eclipse being terrible, so my question to the thread: what would you consider the best free IDE for Java? IntelligJ?
|
# ? Apr 12, 2019 16:02 |
|
The one that you like. Try them all and stick with whichever. There are only 3 major ones: Eclipse, Netbeans and Intellij community. All free. There is also VS Code that is not an IDE, but that can work in a pinch. Some people love it. There are a number of smaller ones (jEdit for example) but ... eh, you'd need 2 lifetimes to try them all. Whoever tells you "X is the best IDE" is absolutely completely wrong and you should ignore them.
|
# ? Apr 12, 2019 16:07 |
|
"Intellij is the best IDE"
|
# ? Apr 12, 2019 18:54 |
|
John F Bennett posted:"Intellij is the best IDE" This is not an empty quote.
|
# ? Apr 12, 2019 19:00 |
|
I am bad at programming so I cut and paste code between all three depending on what I am trying to accomplish. IDEA has some nice quality of life things that Eclipse doesn't but I have a Swing UI idiot proof layout manager setup on Eclipse that I am too dumb to get working on IDEA. I should also mention that all my uses are for college classes so I am new and as a result inherently slow and not good.
|
# ? Apr 12, 2019 19:39 |
|
Nostalgia4Ass posted:I am bad at programming so I cut and paste code between all three depending on what I am trying to accomplish. IDEA has some nice quality of life things that Eclipse doesn't but I have a Swing UI idiot proof layout manager setup on Eclipse that I am too dumb to get working on IDEA. I can't tell if this is a joke post...
|
# ? Apr 13, 2019 12:08 |
|
|
# ? May 9, 2024 03:16 |
|
John F Bennett posted:"Intellij is the best IDE" I regret not having the guts to simply post this. But it doesn't matter, really. Every IDE will tell you you've written something wrong, no IDE will tell you've made something poo poo.
|
# ? Apr 13, 2019 12:24 |