|
Volguus posted:And lombok doesn't process the source code, it processes the AST and the bytecode. The AST you get after the syntax analysis phase, and the bytecode after the actual compilation. The actual source code has been processed already, only after that lombok itself kicks in. This, therefore, does not meet your definition of a pre-processor. There's an implementation that is literally a preprocessor (unless you want to argue that delombok somehow isn't one?). To me, that's sufficient to call the project a preprocessor even if there are alternate implementations that use a different mechanism to achieve the same thing.
|
# ? Feb 22, 2015 05:46 |
|
|
# ? Jun 13, 2024 05:19 |
|
Volguus posted:And lombok doesn't process the source code, it processes the AST and the bytecode. The AST you get after the syntax analysis phase, and the bytecode after the actual compilation. The actual source code has been processed already, only after that lombok itself kicks in. This, therefore, does not meet your definition of a pre-processor. Cool, it has a postprocessing step too.
|
# ? Feb 22, 2015 17:17 |
|
foonykins posted:This is precisely where I'm hung up. Would another set of copies solve this issue? Would it, in sorts, work a kind of save-state when the method is called again? Maybe not the solution, but one thing that makes me feel you are not doing it in the best solution, How are you determining the no repetitions? The moment I hear no repetitions I start looking at Map HashMap to be precise. as Maps cannot have duplicate keys.and you could also store the nnumber of times the item is seen in the value if needed. I will admit i an half asleep here just relaxing before heading to bed.
|
# ? Feb 22, 2015 20:36 |
|
Volmarias posted:And to follow up, if you're allowed to for homework, you should just use StringBuilder. A typical novice mistake for java is to do what you're doing, which is to build a string by appending to an accumulator string over and over, since that involves creating a new builder and a new immutable string in every single round of your loop. It's worth noting (for someone still learning the difference) that this is only really true in the case where you have a loop. I've frequently seen it get cargo culted to every time strings are being concatenated. code:
code:
|
# ? Feb 25, 2015 08:33 |
|
JimboMaloi posted:To be honest I also might argue against concerning yourself with the performance gains of using StringBuilder in a loop until you know you need it, but that's more personal preference. I'd argue the opposite; it's good practice always to use it in a loop (unless you have given your loop a very short, very explicit duration, e.g. i = 0-2), in recursive calls, etc, since you can't guarantee that your mock up code won't end up being permanent and with a vastly increased scope. It's only a little extra work to do it, and you're doing it right.
|
# ? Feb 25, 2015 12:21 |
|
Is there a rule of thumb or best practice on how much code to put in an actionlistener?
|
# ? Feb 26, 2015 23:05 |
|
dev null posted:Is there a rule of thumb or best practice on how much code to put in an actionlistener? The smallest amount needed to complete your task. But that goes for any method.
|
# ? Feb 27, 2015 01:15 |
|
I'm trying to build and run jMAVSim. When I tried to build the project in IntellliJ IDEA under Java 1.8.0_31, I get these errors:quote:F:\jMAVSim\jMAVlib\src\me\drton\jmavlib\conversion\RotationConversion.java I tried "fixing" what the IDE didn't like by changing, adding (existing objects), or removing arguments and in one case changing an import statement ("import org.la4j.matrix.Matrix;" to "import org.la4j.Matrix;"). That allowed the project to build, but I can't find the jar file anywhere. First of all, were the changes I made appropriate? If not, what should have been done? If I'm ok through the build step, what do I need to do to generate a jar file?
|
# ? Mar 8, 2015 20:05 |
|
Did you git clone --recurse-submodules ? They are using submodules for dependency management. It looks like you might be using the wrong commit for those dependencies. There's an ant script to build a jar (you can call it from the `Build` menu in IDEA).
|
# ? Mar 8, 2015 20:43 |
|
Sedro posted:Did you git clone --recurse-submodules ? I did not, since I didn't know about that command. Did that and ant ran fine. However, I can't run it; when I try from the command line I get the message "Could not find or load main class". hooah fucked around with this message at 00:41 on Mar 9, 2015 |
# ? Mar 9, 2015 00:38 |
|
Who knows... they offer no instructions about building or running the software. You could try running it through the IDE. If that works, I think IDEA can make you a JAR somehow.
|
# ? Mar 9, 2015 01:19 |
Hey guys, I need wiser and more patient heads than my own to help me with a Java/JSP problem that keeps cropping up. I have openjdk8 installed (FreeBSD). I'm running tomcat8 like this, which is the default configuration installed by the tomcat package: /usr/local/bin/jsvc -java-home /usr/local/openjdk8 -server -user www -pidfile /var/run/tomcat8.pid -wait 30 -outfile /usr/local/apache-tomcat-8.0/logs/catalina.out -errfile &1 -classpath /usr/local/apache-tomcat-8.0/bin/bootstrap.jar:/usr/local/share/java/classes/commons-daemon.jar:/usr/local/apache-tomcat-8.0/bin/tomcat-juli.jar -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/apache-tomcat-8.0/conf/logging.properties -Djava.endorsed.dirs=/usr/local/apache-tomcat-8.0/endorsed -Dcatalina.home=/usr/local/apache-tomcat-8.0 -Dcatalina.base=/usr/local/apache-tomcat-8.0 -Djava.io.tmpdir=/usr/local/apache-tomcat-8.0/temp org.apache.catalina.startup.Bootstrap I have a JSP page with this in it: code:
code:
I hosed with this a little while ago and swapped out libraries and things and it mysteriously started working, but then last night it broke again (I suspect after I rebooted, implying that something changed in the tomcat startup parameters). Thing is, I don't have any idea where to look to see why it's not finding these libraries. I poke through /usr/local/openjdk8 and nothing looks familiar. People discussing problems like this seem to usually point to JAVA_HOME not being set properly, but I've got it set in my (root) environment, and -java-home is being specified in the tomcat startup options. Can someone please help me understand what's going on here? Thanks.
|
|
# ? Mar 9, 2015 14:05 |
Here's a more focused demo of the above:code:
code:
code:
code:
|
|
# ? Mar 9, 2015 16:25 |
|
Are you using an openjdk version designed only to be run on a headless server? There's specifically headless distributions that IIRC don't even have the AWT and Swing packages in them. Normally Java will run with the libraries but throw an exception if it tries to setVisible() in headless mode. That still allows for rendering to images and printing but if you don't need that, you don't need the libraries.
|
# ? Mar 9, 2015 18:10 |
Yeah, I do need the graphics libs; I'm directly using stuff like ImageIcon. I'll check to see if there's a headless version that I installed by mistake or something. E: Not that I can tell. There's a /usr/local/openjdk8/jre/lib/amd64/libawt_headless.so in the install; I'm not sure what that tells me though.
|
|
# ? Mar 9, 2015 19:41 |
There are installable ports for openjdk8 (which includes a jre), and openjdk8-jre; I only had the former installed, now I'm trying the latter. Both have (in different places): code:
Tried running with -Djava.awt.headless=true too. E: And just to be clear: it only seems to be <c:> that fucks everything up. If I change this one particular <c:set> near the top of the file: <c:set var="basepath_local" value="${sessionScope.basepath}" scope="page" /> to <c:set var="basepath_local" scope="page" value="/usr/local/apache-tomcat-8.0/webapps/ROOT" /> Then it all works fine, including the ImageIcon calls and stuff that uses awt/swing. And it's not because of sessionScope; same thing happens if I use a variable from a different scope. Data Graham fucked around with this message at 20:03 on Mar 9, 2015 |
|
# ? Mar 9, 2015 19:56 |
Hokay. So what it seems to be doing is tryingand failing, for some unknown reasonto set a variable, but then afterwards whatever was causing the exception recovers its bearings and everything is fine. I had a <c:catch> around some input validation stuff a little further down the initial page I was working on, which was swallowing the java.awt exception and then allowing the rest of the script to proceed normally, including all the stuff using AWT. That's what was making debugging this thing so confusing. So here's what works, 100% of the time so far: code:
|
|
# ? Mar 9, 2015 20:43 |
|
Unfortunately I don't know much about JSP, just classloading issues so take this with a grain of salt. The stack trace points to it happening during the creation of the ELContext which apparently happens during the loading of the JSTL. Apparently the following bug fix started loading every package from the import: https://bz.apache.org/bugzilla/show_bug.cgi?id=57142 So I'm guessing it's not finding the package in the ELContext for Expression Language parsing and gives the error. Everything else doesn't care I guess if they're not using the EL. Maybe factor out any AWT/Swing code so that it's not in a servlet page?
|
# ? Mar 9, 2015 22:18 |
It's not a servlet, just a plain old JSP. I've never done anything with servlets, and am pretty unclear on what goes into making one. I've been trying to hackishly try tomcat6 to check if that fix is to blame but can't get it running properly. The page in question is an image uploader. I'm setting various session variables and then calling this JSP via AJAX with a form post. Theoretically the session variables should all be available, and they are, but apparently when the JSP is first being initiated the first JSTL <c:set> tag that refers to an external variable triggers this weird "can't find java.awt" thing. Like, I can <c:set var="foo" value="bar" /> but not <c:set var="foo" value="${bar}" />. So this also works: code:
Data Graham fucked around with this message at 23:09 on Mar 9, 2015 |
|
# ? Mar 9, 2015 23:07 |
|
That ${foo} is the expression language that I was mentioning so anything that uses it initializes an ELContext which is what's trying to load java.awt to my knowledge. My recommendation is to put that code into a plain old java class that you reference from the page rather than including the image manipulation logic there.
|
# ? Mar 9, 2015 23:26 |
Aha, I see. Thanks, I'll try that.
|
|
# ? Mar 10, 2015 02:06 |
I apologize in advance for this. I wouldn't want my worst enemy to have to stare down the barrel of a keytool question. Trying to import a newly generated code signing cert from GoDaddy. The file is in .spc format, which I take to mean PKCS#7. I'm following these instructions, which people seem to be saying are good: https://support.godaddy.com/help/article/4780/java-code-signing-generating-a-csr But maybe they're written for a different version of java or something, because in steps 3 and 4, the -storepass option seems to require an argument in my version, but they seem to think you can just toss it in there without one. (If I leave it out, it prompts me for the password, which I prefer anyway.) But I keep getting this: code:
code:
I'm not sure what to do from here. Anyone wrestled with this one lately?
|
|
# ? Mar 10, 2015 22:09 |
|
There's nowhere in those instructions any mention of a spc file. Get the .cer file and execute (as per the instructions):code:
(no idea where the .cer file comes from since the IT guy did the actual transaction with CC payment and stuff, but ... if he could manage it, so can you).
|
# ? Mar 11, 2015 00:19 |
|
Data Graham posted:I apologize in advance for this. I wouldn't want my worst enemy to have to stare down the barrel of a keytool question. If you can open that .spc file in a text editor and it's actually readable then you are using a PEM encoded file and keytool only likes DER/CER encoded files. I know you used it to print the contents of the .spc file but I think that's confusingly the only use case where it will accept a PEM file.
|
# ? Mar 11, 2015 00:57 |
Nah, it's in the right format; apparently GoDaddy always uses .spc for its files, which are in binary PKCS#7. Which you can clearly infer from their download page: Turns out I was using the wrong alias name, as I should have been able to figure out from the helpful exception message, I guess. (Also it seems openjdk has its own ideas about what kinds of options keytool should support, so you use -importcert instead of -import, but -import still works as an alias to -importcert, even though it isn't listed in the options) Data Graham fucked around with this message at 02:48 on Mar 11, 2015 |
|
# ? Mar 11, 2015 02:26 |
|
Can someone help me understand possible reasons that this method would return an uppercase'd sha256? It seems to me like the method would be returning a completely different and unique has than the one that was created. Does sha256 only produce numeric/alpha lowercase output or something?code:
|
# ? Mar 12, 2015 22:59 |
|
Sample output from that method: 5459-4125-710512670-268175-15-16-17-501490-5011710454-105-5-1260101-9692-113-771994 I suspect whoever wrote that wanted hex output but never tested it. I don't think that method is useful at all in its current form.
|
# ? Mar 13, 2015 00:22 |
|
I guess I accidentally hit preview instead of post, so here it goes again. I'm kind of rusty on my Java, and in my software engineering class they're teaching us the ins and outs of Java instead of the the finer practices of software engineering or whatever they're supposed to be teaching us. I'm supposed to take this .txt file: code:
code:
quote:-Each line may contain various numbers of integer score numbers (line one above contains three integer scores, whereas line three only contains two integers) This is what I have so far, but I have a nagging suspicion that I'm going about it completely wrong. Java code:
edit: you can ignore the empty writeAverageScore method, I forgot to delete it after deciding using multiple methods would be slightly more annoying FAT32 SHAMER fucked around with this message at 08:11 on Mar 13, 2015 |
# ? Mar 13, 2015 08:04 |
|
I'd say that you should read through the file line by line rather than token by token. Then you can further tokenize that line (String.split(' ') will be convenient here) and go through each token on that line, knowing that the first is the first name, the second is the last name, and that each further token should be convertible to an integer. If it isn't, you know it's garbage and can skip.
|
# ? Mar 13, 2015 16:54 |
|
carry on then posted:I'd say that you should read through the file line by line rather than token by token. Then you can further tokenize that line (String.split(' ') will be convenient here) and go through each token on that line, knowing that the first is the first name, the second is the last name, and that each further token should be convertible to an integer. If it isn't, you know it's garbage and can skip. Hmm, so I tried this: Java code:
|
# ? Mar 13, 2015 20:54 |
|
Yeah, you have to split a string. So get the whole line out of the input, and split that (you only need to split on a space.) Then ignore the scanner for working on that line, instead use Integer.valueOf or similar to make ints out of the number for each score. Think of how you could identify both blank lines, and garbage data (for the latter case, do you want to check ahead, or check for failure?)
carry on then fucked around with this message at 21:20 on Mar 13, 2015 |
# ? Mar 13, 2015 21:17 |
|
carry on then posted:Yeah, you have to split a string. So get the whole line out of the input, and split that (you only need to split on a space.) Then ignore the scanner for working on that line, instead use Integer.valueOf or similar to make ints out of the number for each score. Think of how you could identify both blank lines, and garbage data (for the latter case, do you want to check ahead, or check for failure?) Okay I'm starting to get it, plus it didn't help that it didn't like \s instead of " " Java code:
I did a test run by printing every line to make sure it got cleaned up and it did, which is good, but it doesn't seem to like me assigning certain tokens to variables. edit: the error means the code tried to access element index 1 of an array that has less than 2 elements. Not sure how that's possible since every line should have fName/lName/t1/t2/t3 5 elements [0]-[4] FAT32 SHAMER fucked around with this message at 22:13 on Mar 13, 2015 |
# ? Mar 13, 2015 22:09 |
|
Think about which line in your input file might only have one token. That should tell you what you need to check for to avoid one of the instances of malformed data the assignment mentions.
|
# ? Mar 13, 2015 22:12 |
|
Are you using an IDE? Saddle up that debugger, and let's mosey
|
# ? Mar 13, 2015 22:27 |
|
Tusen Takk posted:edit: the error means the code tried to access element index 1 of an array that has less than 2 elements. Not sure how that's possible since every line should have fName/lName/t1/t2/t3 5 elements [0]-[4] This assumption isn't quite right. Take another look at the extra info you posted; it's crashing because of one of those issues. And seconding the debugger, using it should show you a bit more about how things are actually happening.
|
# ? Mar 13, 2015 22:36 |
|
I totally forgot that the last line of the input file had four scores associated with the student Java code:
FAT32 SHAMER fucked around with this message at 22:49 on Mar 13, 2015 |
# ? Mar 13, 2015 22:46 |
|
If you're dead-set on that Scanner class, why not use while(scanner.hasNextLine()) as your loop?
|
# ? Mar 14, 2015 00:12 |
|
Volguus posted:If you're dead-set on that Scanner class, why not use while(scanner.hasNextLine()) as your loop? Im supposed to use the scanner class as per the assignment, but I didn't know if that while loop would work since line 2 of the .txt file is a blank line
|
# ? Mar 14, 2015 00:46 |
|
Tusen Takk posted:Im supposed to use the scanner class as per the assignment, but I didn't know if that while loop would work since line 2 of the .txt file is a blank line I guess there's only one way to find out. And if you absolutely must use the scanner, please use whatever expletive you want on the teacher. He/she deserves it. And after you're done with the school, forget that it even exists, please.
|
# ? Mar 14, 2015 01:10 |
|
|
# ? Jun 13, 2024 05:19 |
|
Volguus posted:I guess there's only one way to find out. I've been told by many users on this site that based on the assignments I come in the CoC looking for help, it's best to just forget everything I learn from the classes and try to absorb as much good practices as I can in a real job. Luckily, I have one lined up starting in late April/early May, so that will definitely help me grow
|
# ? Mar 14, 2015 01:17 |