|
Cool, I didn't see those.
|
# ? Aug 27, 2010 03:51 |
|
|
# ? Apr 29, 2024 08:13 |
|
Yeah, Guava and Apache Commons are pretty useful. I like to use Guava when I get to use Java 6 (we frequently do Java 5 at work) because it uses generics, where as Commons does not, either by lack of maintenance or intentional support of Java 4.
|
# ? Aug 28, 2010 15:50 |
|
Chairman Steve posted:Yeah, Guava and Apache Commons are pretty useful. I like to use Guava when I get to use Java 6 (we frequently do Java 5 at work) because it uses generics, where as Commons does not, either by lack of maintenance or intentional support of Java 4.
|
# ? Aug 28, 2010 16:33 |
|
I am only researching the feasibility of this idea. I know that this is ridiculously low level stuff for Java and I'll probably get laughed out of here but has anyone here ever heard of using Java to bit-bang a SPI interface or interfaced with a USB to SPI adapter? Would it be possible to control single I/O pins in a serial port or other general I/O pin? Could Java supply an appropriate clock of ~48kHz? From my research the best bet would be to use a C or assembly library wrapped in JNI to do the dirty stuff.
|
# ? Aug 30, 2010 14:57 |
|
Kaltag posted:I am only researching the feasibility of this idea. We did something like this recently, using RXTX (new version/info here). It uses JNI internally, but it's pretty easy for the programmer. We used it for both direct serial connections and serial/USB adapters, and it worked fine for both. We probably used an older version too, but I don't remember for sure. I can't say it has exactly what you want, because it seems like you want something possibly even more low level. Kilson fucked around with this message at 21:33 on Aug 30, 2010 |
# ? Aug 30, 2010 21:30 |
|
I want to write a program that will allow users to "code" while running the program, perhaps in java, perhaps in a scripting language that I create (whatever language they end up using will have to be robust enough to allow all of the basic functionality of your everyday programming language, i.e. loops, data structures etc.). Is there an easy way to implement this in java?
|
# ? Aug 31, 2010 05:43 |
|
To clarify: you want to write a java program which will evaluate code (written in some language) which is intended to manipulate the already-running program?
|
# ? Aug 31, 2010 05:55 |
|
Yes =D
|
# ? Aug 31, 2010 05:56 |
|
Calef posted:Yes =D One way to do this is to take the user's code, interpolate that with your program's code, save to file and compile, then run the new program sending in your current settings to load in some fashion, then terminating while the new program continues. Another way is to write your own run time compiler and integrate. Unless you're doing it for academic reasons, I don't see why though.
|
# ? Aug 31, 2010 06:30 |
|
First cardinal rule of Java : There's probably a library for that . As for injecting the logic back into your code you'll want to look up dependency injection for a good start. EDIT : I dug up some stuff from my undergrad. Please be kind, I haven't even thought about this for years so its pretty ugly Shavnir fucked around with this message at 06:35 on Aug 31, 2010 |
# ? Aug 31, 2010 06:32 |
|
Maybe something like http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/ or Groovy will work for you.
|
# ? Aug 31, 2010 10:09 |
|
Shavnir posted:First cardinal rule of Java : There's probably a library for that . It's worth noting that, despite appearances, this API is a thin wrapper that calls javac and leaves compiled .class files sitting around as if you'd called it from a shell.
|
# ? Aug 31, 2010 13:24 |
|
Is there a way to access system commands on a JFrame from another JFrame? I've currently got a method that is called when one frame is closed/the cancel button is pressed that I want to close both the current frame, and another associated frame. Right now the method is:code:
|
# ? Aug 31, 2010 13:30 |
|
quote:I want to write a program that will allow users to "code" while running the program, perhaps in java, perhaps in a scripting language that I create (whatever language they end up using will have to be robust enough to allow all of the basic functionality of your everyday programming language, i.e. loops, data structures etc.). JSR-223 http://today.java.net/pub/a/today/2006/09/21/making-scripting-languages-jsr-223-aware.html It is pretty trivial to make this go. There are many scripting languages available, Python, Ruby, Groovy, Javascript.
|
# ? Aug 31, 2010 14:14 |
|
Awesome, thanks a bunch guys I think JSR-223 is exactly what I need Calef fucked around with this message at 15:26 on Aug 31, 2010 |
# ? Aug 31, 2010 15:06 |
|
Which profiler do you guys recommend for remote J2EE applications? I'm really interested in viewing which queries are taking the longest to return when the system is under heavy load. I have a few stress tests setup that I'm going to run from like 10 machines and each one is going to simulate like 50 clients. I know it's not enough to kill the server, but I hope to see some interesting data. I also need to be able to save the data that it generates to later review it.
|
# ? Aug 31, 2010 15:33 |
|
fart factory posted:This closes the frame fine, but although the owner frame is no longer displayed, the thread continues to run. I wanted to use System.exit(0) on the owner frame, but don't know if this is possible. System.exit(0) is very, very rarely a workable solution. I try to avoid it whenever possible. That said, would this: http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation(int) ...plus this: http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE ...do the trick?
|
# ? Sep 1, 2010 01:05 |
|
I've been playing around with JSR233 and I have one quick questions. I would like to be able to run a script and have it augment a variable in my main java class without having to do something like: class main{ oldvariable = blah; script = "oldvariable = oldvariable + foo;"; scriptengine.eval(script); oldvariable = scriptengine.get(augmentedoldvariable);*** } In other words, I want to tie in the ***'d line into the evaluation of the script somehow so that a user doesn't have to rely on methods I've created to alter variables not-in-the-user-scripted program. I don't know if that made any sense. It wouldn't actually be difficult at all to write those methods, but I'd still like to know if it's possible. Calef fucked around with this message at 06:25 on Sep 1, 2010 |
# ? Sep 1, 2010 06:17 |
|
Have you looked into the SimpleBindings class? You can bind variables from the running program into your scripts and pass them in. http://download.oracle.com/javase/6/docs/api/javax/script/SimpleBindings.html
|
# ? Sep 1, 2010 14:14 |
|
Shavnir posted:First cardinal rule of Java : There's probably a library for that . Unless you're writing Blackberry apps. Then you're hosed.
|
# ? Sep 1, 2010 21:06 |
|
Chairman Steve posted:System.exit(0) is very, very rarely a workable solution. I try to avoid it whenever possible. Yeah, I was only intending to use it to try and kill the process, turns out I don't need to. Just set the parent window to hidden when the dialog was closed or cancelled. Thanks
|
# ? Sep 3, 2010 12:50 |
|
1k pardons if this question has been answered to death. Can anyone recommend to me a good, free pdf writing library?
|
# ? Sep 3, 2010 23:05 |
The Sphinxster posted:1k pardons if this question has been answered to death. I use Flying Saucer. Works great, just make sure your HTML is perfect or it will throw a fit.
|
|
# ? Sep 3, 2010 23:48 |
|
I also use Flying Saucer (as a Grails plugin, but it's still Flying Saucer under the covers) and I will also recommend it. I did have some issues with its ability to handle certain types of CSS but it's better than writing postscript.
|
# ? Sep 4, 2010 02:30 |
|
Anyone recently been wondering what the hell happened to itext? It used to be great.
|
# ? Sep 4, 2010 03:45 |
|
epswing posted:Anyone recently been wondering what the hell happened to itext? It used to be great. Didn't Lowagie make the license burdensome? I won't be able to upgrade to the latest for work stuff.
|
# ? Sep 4, 2010 03:55 |
|
How do I get a proper mod operator in Java? I had a piece of code that I think did it, but I saved it in one of my 200 random text files and lost it. Proper being: Python >>> print -13 % 64 51 Java System.out.println(-13 % 64); -13 I want Python's mod. Edit: Of course I find a page solving it right after I post. This works: code:
Malloc Voidstar fucked around with this message at 18:13 on Sep 6, 2010 |
# ? Sep 6, 2010 17:30 |
|
Aleksei Vasiliev posted:
That doesn't work if (a % b) + b overflows. You can always cast to long and do (a + 0x100000000l * b) % b.
|
# ? Sep 7, 2010 01:08 |
|
If you're worried about overflow, you might as well just accept two longs and return a long, unless you're worried about memory consumption.
|
# ? Sep 7, 2010 13:04 |
|
Chairman Steve posted:If you're worried about overflow, you might as well just accept two longs and return a long, unless you're worried about memory consumption.
|
# ? Sep 7, 2010 16:19 |
|
Fly posted:That would reintroduce the possible overflow condition. BigInteger, then? You can still overflow that, however your number will be ridiculously large at that point anyway.
|
# ? Sep 7, 2010 17:23 |
|
Parantumaton posted:BigInteger, then? You can still overflow that, however your number will be ridiculously large at that point anyway. BigInteger never overflows. Not to mention that you can't use Java's % operator anyway, you would have to write a custom method or hope that BigInteger.mod() behaves the way you want. quote:Semantics of arithmetic operations exactly mimic those of Java's integer arithmetic operators, as defined in The Java Language Specification. For example, division by zero throws an ArithmeticException, and division of a negative by a positive yields a negative (or zero) remainder. All of the details in the Spec concerning overflow are ignored, as BigIntegers are made as large as necessary to accommodate the results of an operation. http://download.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html
|
# ? Sep 7, 2010 19:34 |
|
Chairman Steve posted:If you're worried about overflow crazyfish posted:BigInteger never overflows. Not to mention that you can't use Java's % operator anyway, you would have to write a custom method or hope that BigInteger.mod() behaves the way you want. System.out.println(properMod(-13, 64)); System.out.println(modBig(-13, 64)); // Uses standard a.mod(b); -13 51 51 Looks like BigInteger uses a real modulus, not Java's weird remainder thing.
|
# ? Sep 8, 2010 11:23 |
|
BigInteger has also a remainder method, which is defined in terms of the %-operator.
|
# ? Sep 8, 2010 12:29 |
|
I have a "Connection" class which connects to an application and then maintains information about the connection with getters and setters and other useful bits. This connection class lives in a tomcat application. Each user that uses this needs to use the Connection class. I initially set this up as a singleton class, but that meant only one connection could occur in the jvm. I set it up then as a plain class but now the connections are getting trampled by eachother. The last user to connect is now the sole connection, essentially. This is bad (software design on my part)! What is the answer here? Is making this serializable the easy answer? Would I be required to store that connection data to a stream? Or is this a deeper issue or some other easy solution?
|
# ? Sep 8, 2010 21:03 |
|
I have a JTable which is bound to my EventTracker bean, essentially a wrapper around a list which I will use as append/clear only (i.e., a simple log). Problem is, when I add entries to the list and try to fire an event I don't see any changes. I'm using the NetBeans IDE. The EventTracker bean is added to the view and instantiated as eventTracker1. From there, I right click on the table and choose 'Table Contents...'. Table model is bound to eventTracker1, binding expression is '${eventList}'. The columns are set up properly to operate on the entries in eventList. code:
|
# ? Sep 8, 2010 21:18 |
|
mister_gosh posted:What is the answer here? Is making this serializable the easy answer? Would I be required to store that connection data to a stream? Or is this a deeper issue or some other easy solution? Why not use connection pooling? You can potentially take a page from the JDBC API - they have a DataSource object which may (or may not) be used to represent a connection pool from which Connection[2] objects are either checked out or created (as needed). When a consumer invokes the close method on the Connection object, it's not physically closed - it's checked back into the connection pool, where it waits to either be checked out by another consumer or physically closed by the connection pool per whatever eviction policy it follows. 1. http://download.oracle.com/javase/6/docs/api/javax/sql/DataSource.html 2. http://download.oracle.com/javase/6/docs/api/java/sql/Connection.html
|
# ? Sep 9, 2010 04:11 |
|
Why do people use arrays? This might sound stupid but it seems to me that ArrayLists are better in pretty much every way.
|
# ? Sep 10, 2010 01:16 |
|
Chinapwns posted:Why do people use arrays? This might sound stupid but it seems to me that ArrayLists are better in pretty much every way. Also, arrays are still cheap, and if you're encapsulating them, and you don't need them to change, they're still a great way to hold data sometimes. Also, the Java language has a syntax for array literals, but not so for any of the collections, yet.
|
# ? Sep 10, 2010 01:19 |
|
|
# ? Apr 29, 2024 08:13 |
|
Fly posted:Also, the Java language has a syntax for array literals, but not so for any of the collections, yet. Arrays.asList() to the rescue!
|
# ? Sep 10, 2010 03:14 |