|
CBA: if you want to store that number as a Long you can docode:
|
# ? Apr 28, 2010 00:03 |
|
|
# ? May 25, 2024 18:13 |
|
Is there any way to make a Java program run itself in the background on Linux? Like say I have upfile.jar, and running upfile.jar bigfile.avi will upload bigfile.avi to my FTP server. Is there any way for the program -- not any extra terminal commands, but the jar itself -- to detach from the terminal and run as a background process/daemon?
|
# ? Apr 28, 2010 03:32 |
|
With the bash shell you can end any command with an '&' to launch something as a background process.code:
|
# ? Apr 28, 2010 03:34 |
|
Internet Janitor posted:With the bash shell you can end any command with an '&' to launch something as a background process. Tack a 'nohup' onto the front of that so it wont kill the process when you log out.
|
# ? Apr 28, 2010 18:34 |
|
^^^^ You may need to do nohup java -jar upfile.jar bigfile.avi > /dev/null 2> /dev/null < /dev/null & if it still hangs Not sure if the terms are completely correct, but does anyone know the scope of the final-ism of a variable? What I want to do is to make sure an object doesn't re-assign itself after it's created. code:
Colonel Taint fucked around with this message at 02:39 on Apr 29, 2010 |
# ? Apr 29, 2010 02:32 |
|
SintaxError: I think you're rather confused. When a reference is 'final' it simply means that reference cannot be altered once it has been assigned, either at declaration or in a constructor. Arguments to a method cannot be 'final', and it wouldn't really mean anything in that context- references would be passed by value anyway. The keyword 'this' evaluates to a reference to the current object- it isn't a variable you can assign to a different reference. What do you expect would happen if an object "re-assigned itself"? None of that makes any sense.
|
# ? Apr 29, 2010 02:42 |
|
Ah, my bad. That's what I get for coming from a C++ background, where it's perfectly valid (though perhaps not always the best idea) to change what this points to. Edit: that's apparently no longer true. Java references confuse me Colonel Taint fucked around with this message at 03:08 on Apr 29, 2010 |
# ? Apr 29, 2010 03:00 |
|
Arguments to a method can be declared final in the implementation although it's not allowed in an abstract method. This simply indicates that the method will not change the values passed in even if pass by value semantics are enforced on all method calls normally. This is required if the values are to be accessible from within a local class defined inside the method. Otherwise it's merely a helpful indicator for the compiler when optimizing code and a way to ensure that the value isn't changed inadvertently.
|
# ? Apr 29, 2010 03:02 |
|
Internet Janitor posted:With the bash shell you can end any command with an '&' to launch something as a background process. java -jar upfile.jar code:
edit: ignore the fact that this doesn't take a file as an argument, it's from the testing code just for the detaching part Malloc Voidstar fucked around with this message at 07:02 on Apr 29, 2010 |
# ? Apr 29, 2010 06:50 |
|
Is there a way to escape Expression Language results in a JSP file by default? I have ${item.value} in my JSP file, which generates the following code with Tomcat 6.0: code:
code:
|
# ? Apr 30, 2010 11:24 |
|
You mean HTML/XML escaped, right?code:
|
# ? Apr 30, 2010 11:42 |
|
Yes. I could use c:out or roll my own, but I'd rather use ${item.value} for escaped text and <c:out value="${item.value}" escapeXml="false"/> for unescaped text. I've looked at replacing the Jasper compiler in Tomcat with a modified version, but I'd like to find an easier way.
|
# ? Apr 30, 2010 11:59 |
|
There isn't.
|
# ? Apr 30, 2010 12:15 |
|
Hey I was wondering if anyone has the java source code for DFS (depth-first search) maze generation. Here is the algorithm written as psuedocode. I need to generate a maze within JFrame composed of cells. create a CellStack (LIFO) to hold a list of cell locations set TotalCells = number of cells in grid choose a cell at random and call it CurrentCell set VisitedCells = 1 while VisitedCells < TotalCells find all neighbors of CurrentCell with all walls intact if one or more found choose one at random knock down the wall between it and CurrentCell push CurrentCell location on the CellStack make the new cell CurrentCell add 1 to VisitedCells else pop the most recent cell entry off the CellStack make it CurrentCell endIf endWhile
|
# ? May 3, 2010 00:57 |
|
Private Message: Are you having difficulty with the Swing stuff, or maze generation itself? For the UI, it should be as simple as extending a JFrame, calling getContentPane() to get the base component and calling getGraphics() on that to get an AWT Graphics context you can use to draw whatever you want. Alternately, you could set the content pane's layout manager to a GridLayout of appropriate dimensions, to which you could add JPanels (or JButtons, or whatever) representing each tile in the maze. As for implementing the algorithm, uh... you have pseudocode- why don't you take a crack at implementing it and get back to us if you run into any specific trouble? I don't mind giving advice, but I'm not going to do your homework for you.
|
# ? May 3, 2010 01:35 |
|
private message posted:Hey I was wondering if anyone has the java source code for DFS (depth-first search) maze generation. Yeah wait a minute, you want us to just give you the source code, aka, the answer for your homework? Doesn't work like that, bub.
|
# ? May 3, 2010 16:33 |
|
When I used to work in PL/SQL it had the ability for me to compared a string to a comma separated list of other strings like this:code:
code:
|
# ? May 4, 2010 15:55 |
|
Sure, if you don't mind possible performance implications for some definition of "a lot of things":code:
|
# ? May 4, 2010 16:03 |
|
Teeheecode:
code:
epswing fucked around with this message at 21:58 on May 4, 2010 |
# ? May 4, 2010 16:15 |
|
As the number of things increases, you might consider using some kind of Set like a HashSet or a TreeSet. These data structures are perfect for membership testing.
|
# ? May 4, 2010 19:15 |
|
Does anyone have any experience with Java certification exams? Are they worth going for or just a waste of time next to practical ability?
|
# ? May 4, 2010 21:13 |
|
epswing posted:
This is completely pointless. The only reason to do hashtable lookup instead of a linear scan is that it's O(1), but building the hashtable in the first place is O(N), and it's a fairly heavy O(N) at that. At the very least you should build the hashtable in a static field. It is also quite possibly faster to call String.equals three times than it is to do a hash lookup.
|
# ? May 4, 2010 21:32 |
|
If you didn't notice the "Teehee," this was a comedy 'contains' option. vvv Edit: No problemo, and actually, thanks for the asymptotic analyzing, it's worse than I thought. epswing fucked around with this message at 22:02 on May 4, 2010 |
# ? May 4, 2010 21:47 |
|
epswing posted:If you didn't notice the "Teehee," this was a comedy 'contains' option. Ah, no, I didn't, nevermind.
|
# ? May 4, 2010 22:00 |
|
Partyworm posted:Does anyone have any experience with Java certification exams? Are they worth going for or just a waste of time next to practical ability? Never did them, probably a waste of money and time unless work is paying for it (and time to study for it)
|
# ? May 5, 2010 14:21 |
|
If you've never done them, why do you think your opinion that they're a waste of money is worth anything? I'm not intentionally trying to be a dick, but saying something is a waste of money with zero backup isn't helpful to anyone.
|
# ? May 5, 2010 15:29 |
|
epswing posted:If you've never done them, why do you think your opinion that they're a waste of money is worth anything? Everyone that I know who has taken them says they are a waste, there was a thread on reddit yesterday were everyone said they were a waste also i guess they might be padding if you don't have a degree or something e: also just accepted a new job, during my hunt never saw anything that said "NEED JAVA CERTIFICATION", they all said you need a degree and some experience. lamentable dustman fucked around with this message at 16:27 on May 5, 2010 |
# ? May 5, 2010 16:25 |
|
Partyworm posted:Does anyone have any experience with Java certification exams? Are they worth going for or just a waste of time next to practical ability? Many candidates with certifications seem to come from consulting or contracting backgrounds where the agency probably likes to be able to claim all of their contractors are certified.
|
# ? May 5, 2010 16:57 |
|
Fly posted:Many candidates with certifications seem to come from consulting or contracting backgrounds where the agency probably likes to be able to claim all of their contractors are certified.
|
# ? May 5, 2010 17:44 |
|
I have a textfile in my src folder, like jdbc.properties or whitelist.xml, and when I compile it ends up in my bin folder (or more specifically, my war/WEB-INF/classes folder since I'm in tomcat-land). How can I access whitelist.xml? I thought I'd done this before in a previous life (job), but now I think that was packaging images for JButton icons into a jar, which isn't the same thing. I think I used some System.something call for that, but I can't find it now, and I'm not sure what to search for. I can't reliably snatch whitelist.xml out of the filesystem, because when I start the tomcat server with tomcat/bin/startup.sh the current working directory is wherever I execute that command, obviously, so I can't get to it relatively, and trying to get to it absolutely is just dumb. Edit: speling vvv Edit 2: Gracias! epswing fucked around with this message at 20:23 on May 5, 2010 |
# ? May 5, 2010 19:55 |
|
epswing posted:I have a textfile in my src folder, like jdbc.properties or whitelist.xml, and when I compile it ends up in my bin folder (or more specifically, my war/WEB-INF/classes folder since I'm in tomcat-land). How can I access whitelist.xml? getClass().getClassLoader().getResourceAsStream("whitelist.xml") should get the file as a stream from the classpath root
|
# ? May 5, 2010 20:04 |
|
code:
|
# ? May 6, 2010 04:17 |
|
UraniumAnchor posted:
Just b. Edit: because I like to second guess myself sometimes here's proof of concept (OK not strictly a proof) code: code:
yatagan fucked around with this message at 06:30 on May 6, 2010 |
# ? May 6, 2010 06:18 |
|
yatagan posted:Just b. http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait() quote:The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
|
# ? May 6, 2010 17:52 |
|
I'm a .NET guy, pretty new to Java, and iI have a Struts/EJB question. I'm trying to teach myself some stuff but I'm pretty disappointed in the tutorials I found so far. I have two separate problems:the first, is just getting data from a simple query to display. I have a GetMessagesAction that exposes a "messages" property. I've tried to make this a ResultSet (although if resultset is anything like and ADO.NET DataSet I probably shouldn't use that), a HashMap, and just concatenating everything into a string (which is probably the worst but at least it displays anything). How should I configure my JSP page to display this? <bean:write .../> cuts it for strings, but not for Collections or ResultSets (blank). I tried <logic:iterate.../> but that just gets me a 500 error "No collection found". So I'm actually looking to find something comparable to the ASP.NET GridView or ListView controls. Next, is a system that allows a user to submit a message once he has identified himself. The problem here is that I can get the username from a bean, but I wouldn't know how to pass it to the messaging bean. Load it into session? Get it from one of the form properties in the MessagesAction model?
|
# ? May 7, 2010 08:18 |
|
wigga please posted:I'm a .NET guy, pretty new to Java, and iI have a Struts/EJB question. I'm trying to teach myself some stuff but I'm pretty disappointed in the tutorials I found so far. Any collection should do.. have you tried using <logic:present> to see if it's been loaded / available? Are you able to access the Collection with JSP instead of struts tags? Also, just a quick check - you are including the logic taglib, right? That last one has lead me to many headaches over time. http://struts.apache.org/1.2.9/userGuide/struts-logic.html#iterate As for the second, yes, at my old job we loaded everything into the session scope on success of the Action.
|
# ? May 7, 2010 16:33 |
|
Alright, so I have a small server app that I'm writing, which works fairly well under a small load. However, after about a minute of light stress testing (new connection every 100ms or so, disconnect after ~45 seconds), this happens: Although it still runs fine with the 200 threads (they're mostly in a wait state after running small, async jobs via a cachedThreadPool ExecutorService), I'd really rather have it remain at a somewhat steady thread count. I'm at somewhat of a loss as to how to deal with this. NetBeans's profiler isn't much help. tptp in Eclipse is a bit more useful, but isn't exactly shedding any light on the problem either, and in either case there's way too much going on after the fact for a debugger to be useful... I've pretty much been trying to deal with this all day, so any help/advice would be useful. Colonel Taint fucked around with this message at 17:11 on May 9, 2010 |
# ? May 9, 2010 04:53 |
|
I have a quick/possibly dumb question about . . . well, for each loops I think, I'm not exactly sure what the problem is.code:
|
# ? May 9, 2010 07:13 |
|
HondaCivet posted:I have a quick/possibly dumb question about . . . well, for each loops I think, I'm not exactly sure what the problem is. You should post the rest of the function so we can see why it doesn't work. The only thing I can think of is that you may close too many brackets and you end up outside the loop.
|
# ? May 9, 2010 10:03 |
|
|
# ? May 25, 2024 18:13 |
|
SintaxError posted:Alright, so I have a small server app that I'm writing, which works fairly well under a small load. However, after about a minute of light stress testing (new connection every 100ms or so, disconnect after ~45 seconds), this happens: Does your thread pool really need to be unbounded? You could try fat provisioning your threads by using a fixed thread pool, but that's not as efficient as the cached one for obvious reasons. It's really unfortunate that the cached thread pool doesn't allow you to specify an upper bound on the number of threads it creates, though if your multithreading skills are strong you could probably implement a thread pool that does what you want without a massive amount of work. Also if the asynchronous tasks you're executing have a true async model, you might want to look at using a callbacks instead of threads to carry context. crazyfish fucked around with this message at 16:58 on May 9, 2010 |
# ? May 9, 2010 16:53 |