|
Fly posted:edit: Probably nevermind what I wrote. Authkit seems to have little to do with Java security but instead with Mac OS X security, i.e., running with root privileges. Affirmative. Nevertheless, I appreciate your help. What I'm trying to do is get access to the network interface which requires admin privs (at the level of the operating system, not within the Java framework). I don't want to require that people run my program with sudo or anything tricky.
|
# ? Jan 1, 2009 09:53 |
|
|
# ? May 11, 2024 10:26 |
|
This is mostly a design question. I'm coding a gradebook program as a learning experience, and I've run into a snag. Flow: 1. Course objects are loaded from the database. If the database doesn't exist, create it. These courses are loaded into an array list for easier handling. This is pretty basic and works fine. 2. If a course is added, it's appended to the array list. When the array list is pushed to the database, it needs to see this change and insert it. Problem: How do I compare beyond just comparing strings? 3. Courses need to have assignments, etc. Naturally this is done in a one-to-many relationship, linked by course ID. Problem: How do I match course ID to course object? For existing courses this isn't a huge deal, but for new courses that haven't been pushed to the database yet, this is a big deal (they don't have an ID!) Should I create a method that looks for the last available row and have it assume an ID? That seems a bit sketchy
|
# ? Jan 1, 2009 11:55 |
|
firetech posted:Affirmative. Nevertheless, I appreciate your help. What I'm trying to do is get access to the network interface which requires admin privs (at the level of the operating system, not within the Java framework). I don't want to require that people run my program with sudo or anything tricky. quote:In any Authorization implementation, some Privileges may only be effectively exercised by executing another program (process). The threshold at which this becomes necessary is implementation-dependent. On typical Unix-like systems, a process is the smallest entity that can have distinct enforceable privileges, rather than a thread, a class, or an object. Mac OS X works this way, so if special system-enforced privileges are needed, it may require a separate process to do it. That's why execPrivileged() exists. ijustam posted:Flow: ijustam posted:2. If a course is added, it's appended to the array list. When the array list is pushed to the database, it needs to see this change and insert it. Problem: How do I compare beyond just comparing strings? Usually it's sufficient to give them some artificial id (a number, say). Then you just update the row with the id you want to change. You go on to mention this in the next question. ijustam posted:3. Courses need to have assignments, etc. Naturally this is done in a one-to-many relationship, linked by course ID. Problem: How do I match course ID to course object? For existing courses this isn't a huge deal, but for new courses that haven't been pushed to the database yet, this is a big deal (they don't have an ID!) Should I create a method that looks for the last available row and have it assume an ID? That seems a bit sketchy zootm fucked around with this message at 13:21 on Jan 1, 2009 |
# ? Jan 1, 2009 13:14 |
|
zootm posted:It's usually best to use the capabilities of the database for things like this, rather than loading everything into memory. I'm using SQLiteJDBC. It's possible that there already exists something like it, but I haven't found it yet. There are a lot of column methods but very few row methods.
|
# ? Jan 1, 2009 13:48 |
|
ijustam posted:I'm using SQLiteJDBC. It's possible that there already exists something like it, but I haven't found it yet. There are a lot of column methods but very few row methods. With JDBC stuff you generally write your queries in SQL rather than calling Java methods to do it.
|
# ? Jan 1, 2009 13:53 |
|
zootm posted:For SQLite, look into ROWID for the row id generation you want. OH yeah, that's just getRow(). Are you suggesting I do a "Select *" and just use the last row +1?
|
# ? Jan 1, 2009 14:21 |
|
ijustam posted:OH yeah, that's just getRow(). Are you suggesting I do a "Select *" and just use the last row +1?
|
# ? Jan 1, 2009 14:23 |
|
ijustam posted:This is mostly a design question. I'm coding a gradebook program as a learning experience, and I've run into a snag. How are you pushing the array list to the database? ijustam posted:3. Courses need to have assignments, etc. Naturally this is done in a one-to-many relationship, linked by course ID. Problem: How do I match course ID to course object? For existing courses this isn't a huge deal, but for new courses that haven't been pushed to the database yet, this is a big deal (they don't have an ID!) Should I create a method that looks for the last available row and have it assume an ID? That seems a bit sketchy Now I understand better what you are doing. Here is how I would do it and will follow into your other questions. Most good databases allow you to set a sequence which you ask for a number and it will only give you that number and no one else can ever get that number again (until it rolls over at least). You write a insert query which queries the sequence for what it is inserting. You then ask the database for a query based on the course name to get that number. You will want to make course name unique obviously. Now in memory you should store the course in a Hashmap or TreeMap. You'll probably use the sequence number for the key. If you make a change to this tree, you need a variable to modify it. As for the assignments and such, you give them a field which takes the course id. Don't allow an assignment to be created which doesn't have a course id (can be handled through database triggers). Never assume anything about the state of the database while in your Java code. Databases may change at any time and probably will if you have multiple users. So do not write any code assumes the database won't be modified while you are doing something in Java. Basically assume your program only has a snapshot at a particular time and things may have changed after it. Any code that relies on things being the same as the snapshot, needs to be changed to not make that assumption.
|
# ? Jan 2, 2009 00:19 |
|
I am making a webservice using Axis2 and using "application" scope. I am wondering how I can make my webservice return data without XML? That is I want the response to HTTPRequests to my webservice to just contain whatever the function returned, and no stupid XML wrapping that information.
|
# ? Jan 5, 2009 02:02 |
|
Fehler posted:Does anybody know where I could find sample code for comparing two WAV audio streams in Java? I need a function that returns some kind of "score" telling me how well the two streams match. From what I found on Google it looks like I need to do a Fourier Transformation, but I'm not really sure how to implement that and how to use it. hexadecimal posted:I am wondering how I can make my webservice return data without XML? That is I want the response to HTTPRequests to my webservice to just contain whatever the function returned, and no stupid XML wrapping that information.
|
# ? Jan 5, 2009 05:16 |
|
necrobobsledder posted:You're looking at not just FFTs but statistical methods to comparing data sets and signals like linear time series, clustering, Hidden Markov Models (HMMs), etc. Not exactly a walk in the park for beginners. I'm not aware of any Java libraries to do this though. EDIT: Never mind. I just ended up making a php script that strips out XML and responds with headers I need. hexadecimal fucked around with this message at 18:09 on Jan 5, 2009 |
# ? Jan 5, 2009 05:54 |
|
...
maskenfreiheit fucked around with this message at 03:41 on Sep 29, 2010 |
# ? Jan 6, 2009 22:17 |
|
import statements have to go at the top of the file. I don't know how it got into the middle, but that's very wrong; the compiler even says exactly that (illegal start of expression). e: What probably happened is the author intended each class to be their own files. e2: Or maybe not because you defined GameHelper to be an inner class. Was that the author's code or your own? e3: Hell, your braces don't line up to anything that lets me figure out what you or the author were going for here. Post complete code if there's a problem with it. csammis fucked around with this message at 22:29 on Jan 6, 2009 |
# ? Jan 6, 2009 22:27 |
|
GregNorc posted:words.... They have a weird way of indenting but the GameHelper class should be it's own file (or keep it inside SimpleDotCom and move that import statement). You can only have an import at the head of a file. You'll have to fix the bracketing of the main class.
|
# ? Jan 6, 2009 22:29 |
|
Edit: Double Post
maskenfreiheit fucked around with this message at 21:31 on Mar 13, 2017 |
# ? Jan 7, 2009 00:30 |
|
If you have a public (non-inner) class called Something in package wherever.blah, it has to go into $CLASSPATH/wherever/blah/Something.java. The book probably should've mentioned this, but in future exercises when they have classes like this they mean them to go into separate files. Also, you're missing two }s at the end of the first class.
|
# ? Jan 7, 2009 01:05 |
|
GregNorc posted:Ok... yeah that's what I hate... the book is GREAT at making OO concepts understandable but it has the bad habit of putting a bunch of classes in one java file, then sometimes it wants you to keep a class by itself in it's own little file, and doesn't really distinguish between the two. if you are still having problems this is how it should be. You had some other problems with spelling and stuff too code:
code:
|
# ? Jan 7, 2009 02:23 |
|
I think my webservice is running into dead locks, and makes the whole Axis2 freeze. Is there a way to configure Axis2 such that bugs in my webservice don't gently caress up the whole axis2 service?
|
# ? Jan 7, 2009 02:31 |
|
hexadecimal posted:Is there a way to configure Axis2 such that bugs in my webservice don't gently caress up the whole axis2 service?
|
# ? Jan 7, 2009 02:57 |
|
necrobobsledder posted:Wait, is it tying up the entire application server because Axis2 is hanging (an internal bug then), or can you run other axis2 based servlets in the application server? Other services stop working too. So I guess its tying up all of axis2. It can't even close by itself, I have to force quit it. EDIT: Also I don't get any exceptions print out in TomCat window. vvvv Sorry if this is a really newbie question, but where does tomcat store its logs? hexadecimal fucked around with this message at 03:10 on Jan 7, 2009 |
# ? Jan 7, 2009 02:59 |
|
what application server are you running? anything in the logs?
|
# ? Jan 7, 2009 03:06 |
|
hexadecimal posted:vvvv Sorry if this is a really newbie question, but where does tomcat store its logs?
|
# ? Jan 7, 2009 04:49 |
|
TRex EaterofCars posted:By default it's $CATALINA_HOME/logs/catalina.out where $CATALINA_HOME is the Tomcat installation directory. I see catalina.<date>.log no files with .out extension. I don't see any useful information in those log files, however. I have a hunch it could be because it runs out of memory, however, and the reason is because I get java.lang.OutOfMemoryError: PermGen space in another java program I run (not webservice, but makes HTTPRequests to webservice) on the same machine. Is this a valid hunch?
|
# ? Jan 7, 2009 04:56 |
|
Dunno but it easy to test. Increase java's default heap and max heap space. You can also increase the tomcat heap space in the config somewhere. Where should also be 5 or 6 log files with different things in it.
|
# ? Jan 7, 2009 05:43 |
|
dvinnen posted:Dunno but it easy to test. Increase java's default heap and max heap space. You can also increase the tomcat heap space in the config somewhere. I increased for tomcat, and it seems to work. At least it hasn't frozen in a bit. However it definitely doesn't work for the other app, but that is a separate issue.
|
# ? Jan 7, 2009 05:48 |
|
hexadecimal posted:I see catalina.<date>.log no files with .out extension. I don't see any useful information in those log files, however. Win32 or Linux or ?
|
# ? Jan 7, 2009 06:12 |
|
TRex EaterofCars posted:Win32 or Linux or ? Windows XP SP3. JDK 1.6
|
# ? Jan 7, 2009 06:27 |
|
If increasing your heap size just delays your problem, you might want to go one step further and analyze your memory usage. You can run tomcat with: -XX:+HeapDumpOnOutOfMemoryError This will give you a nice dump file when you crash, so that you can then analyze with some tools. I used an eclipse plugin called Memory Analyzer (MAT) to spot where my problem was in my case. Jconsole also comes with the jdk in the bin directory, and it's pretty handy if you want to see live how your application is doing memory-wise. Although in my case, my memory issues were in the eden/tenured/old gens, not perm.
|
# ? Jan 7, 2009 08:42 |
|
GregNorc posted:Battleships stuff Is it weird that reading through that the first thing I thought of was that the code doesn't take into account that you can only hit a single space once successfully? Unless that's a later part of the tutorial. Sounds like a decent book though. I was thinking of using Battleships as a learning example myself.
|
# ? Jan 7, 2009 14:34 |
|
hexadecimal posted:I have a hunch it could be because it runs out of memory, however, and the reason is because I get java.lang.OutOfMemoryError: PermGen space in another java program I run (not webservice, but makes HTTPRequests to webservice) on the same machine. There's a couple of reasons this can happen in practice:
If you don't think that is what you're actually seeing, it's pretty safe to just increase the amount of PermGen space the JVM has (it's quite low by default since most apps don't require that much). The arguments are: code:
zootm fucked around with this message at 14:53 on Jan 7, 2009 |
# ? Jan 7, 2009 14:50 |
|
edited out
Hammerite fucked around with this message at 19:39 on Jan 7, 2009 |
# ? Jan 7, 2009 19:08 |
|
Which part of that is a Java question?
|
# ? Jan 7, 2009 19:33 |
|
Oh, I'm sorry. I didn't register the fact that this thread is "Java" rather than "Javascript".
|
# ? Jan 7, 2009 19:39 |
|
I'm writing an application that loads classes from jars at runtime. I'm doing this using the URLClassLoader.addURL method. One problem I'm running into is that in some cases I have two versions of the jar I want to use at different points of the application (it's a backwards compatibility test essentially). So what I need to do is unload the first version of the jar then reload another version of the jar so that when I use a class defined in that jar I can be sure that the class is of the correct version. URLClassLoader does not have a way to unload jars or remove then from the URL because, I'm assuming, it's not that easy. I found one site that mentions that the custom class loaders in Tomcat (WebappClassLoader I assume) can do this but I've had a quick look at the code and I'm not seeing how it does it. I had a couple of thoughts... Can I set the URLClassLoader class to null and then call the JVM's garbage collector? Am I unloading all the classes that were loaded from jars in the URLClassLoader's URLClassPath? Can I extend URLClassLoader to remove jars from the URLClassLoader's URLClassPath? If anyone could give me any pointers that would be great. Class loading is something I've not really touched before in my Java programming so apologies if anything I've said above makes no sense. If there's a better way to achieve dynamic loading and unloading of different versions of the same class that would be even better! Thanks. Rhaegar fucked around with this message at 01:56 on Jan 8, 2009 |
# ? Jan 8, 2009 01:49 |
|
How do I get javadoc to generate documentation for inner private classes and their variables and methods? I am using javadoc tool from eclipse, but I could make my own .bat file for this if it's not possible to get eclipse to do this.
|
# ? Jan 8, 2009 05:12 |
|
Rhaegar posted:Can I set the URLClassLoader class to null and then call the JVM's garbage collector? Am I unloading all the classes that were loaded from jars in the URLClassLoader's URLClassPath? Yep. Just make sure that you pay attention to the issues that were mentioned just a bit earlier about PermGen space. There can't be any dangling references to the ClassLoader, Classes or any instances for it to be collected so be careful with static references.
|
# ? Jan 8, 2009 05:54 |
|
zootm posted:PermGen space is where class definitions reside; if you load too many classes, it dies and completely screws the JVM since the GC will start spinning trying to free space. This is very annoying, and if you're seeing that error it is almost definitely the cause of your problem. Thank you so much. This seems to have fixed the problem in my eclipse plugin. However, I still have issue of axis2 locking up on me sometimes. I tried the option another user in this thread suggested, and no dumps or any useful logs are generated. I have some bugs in my webservice, that are probably threading related. However when it becomes unresponsive it blocks all other webservices. How can I make sure that my buggy webservice doesn't make other webservices and axis2 cry, besides the obvious "fix the bugs in the program"?
|
# ? Jan 8, 2009 19:03 |
|
What does ../.. mean when its put in a class path?
|
# ? Jan 9, 2009 17:09 |
|
hexadecimal posted:What does ../.. mean when its put in a class path? Two directories above the current one?
|
# ? Jan 9, 2009 17:10 |
|
|
# ? May 11, 2024 10:26 |
|
hexadecimal posted:How do I get javadoc to generate documentation for inner private classes and their variables and methods? I am using javadoc tool from eclipse, but I could make my own .bat file for this if it's not possible to get eclipse to do this. I think javadoc has a -private option (or something along those lines).
|
# ? Jan 9, 2009 22:47 |