|
Flamadiddle posted:My HTML isn't up to my Java, which isn't up to much. How would you even get an HTML form to submit to the server-side application? With an HTTP Get or something? What kind of webserver are you running? Honestly it sounds like java is over kill if all you need is a interface to get data into the database. I would consider just a PHP or a CGI page in perl or something to handle it. Should be able to find a tutorial online for either of those very easily. To use a HTML you will need a Java application server (Tomcat/Jetty/GlassFish etc) as far as I know. From there it would be easier to write a JSP page. There are other ways of course, HttpServletRequest allows you to read GET data via getParameter(String). It's not a bad idea to set up an app server if you plan to write some more web apps but a little overkill for this project. If you run Apache then setting it up to forward the correct stuff to Tomcat isn't that hard, with IIS it is a little more difficult but doable. Again, I don't think Java is the correct tool for the job here. PHP or a CGI script can open up the database handle you need and keep everything on the server side.
|
# ¿ Sep 18, 2008 03:38 |
|
|
# ¿ Mar 28, 2024 13:18 |
|
icehewk posted:I'm still getting a 'few' errors. I think I'm missing something from the beginning drat dude, I usually like helping people do their homework but you got some serious issues. Lets start with the obvious stuff. code:
With the current iteration why did you remove the BufferedReader? You need that to read the input. What is 'Input' suppose to be? You never declared it, nor did you declare 'input'. Java is case sensitive so it sees those as different variables. From the code last night do this. code:
Later on I notice you are using the variable 'Hours' instead of 'hours'. The variable 'Rate' is also not declared (guess it should be 'payrate'). Next issue are this line: code:
The above should get it close to compiling I would guess. It is obvious you are new to programming here (CS101?) but you need some help. Does you your school offer CompSci tutoring? If not go spend a few hours in the professors office.
|
# ¿ Sep 19, 2008 05:14 |
|
What kind of file are you reading from? Edit: realized I didn't read carefully enough. lamentable dustman fucked around with this message at 18:52 on Sep 21, 2008 |
# ¿ Sep 21, 2008 18:32 |
|
If you need to do a round rather then just round up all you have to do is the following. 1) Divide by 5 2) Subtract .5 (cast to double for all this of course) 3) Call the ceiling function. 4) Multiply that by 5. ex) 24/5 = 4.8 - .5 = ceiling(4.3) = 5 * 5 = 25 ex) 22/5 = 4.4 - .5 = ceiling(3.9) = 4 * 5 = 20
|
# ¿ Sep 21, 2008 22:28 |
|
pearofducks posted:I'm goofing around making a network game (lets call it tictactoe for now), and one player has to wait for the other to take their turn. To do this I have the waiting player sit in an infinite loop checking the input buffer to see if it has data yet, even with low thread priority and a big wait time this still sucks CPU like mad and makes a laptop take off. Is there anything that will let me get away from this loop? Maybe something that pushes the data instead of needing it to be constantly polled? Try thread wait(). Set it to poll every half second or so. Co-worker had to do something similar last week to read from a ESB. Think he used a Thread object and simply told it to poll every second inside a loop. Edit: I'm sure there are better ways to do it, we were pulling a 24 hour day trying to get code up for a demo that was scheduled for 8 in the morning. lamentable dustman fucked around with this message at 06:03 on Sep 24, 2008 |
# ¿ Sep 24, 2008 05:54 |
|
Anyone have experience in image processing? I wrote a servlet that resizes the image on the server side and sends the client a thumbnail of the original picture. Works really well and all. We ran into a issue with a good portion of our pictures are corrupt. We haven't figured out were in the process it is corrupting yet as part of the process is out of our control. Now my servelet has nothing to do with the corruption but they want to see if we can have some kind of checker on it anyways, just for future issues. Doing some googling right now and not seeing much. I'm also pretty sure it isn't possible without a hash to compare against but figured it is worth asking. Looking at files in a HEX editor dosen't show anything I might be about to compare against either. The images are in jpeg format and I am turning them into a BufferedImage for processing. EDIT: I was able to figure it out. The curropt images throws exceptions when you look at the metadata. Ran the code from the guy bellow and was getting "Bogus marker length" from javax.imageio.IIOException. Dude has a good blog, I've learned a lot of Perl tricks from him. http://johnbokma.com/java/obtaining-image-metadata.html lamentable dustman fucked around with this message at 16:10 on Sep 25, 2008 |
# ¿ Sep 25, 2008 15:39 |
|
Is there a way to iterate through every file in a directory? I've been looking at the File class and not seeing a way to do it. This has to do with my question yesterday, I want to clear out all the corrupt images that we are receiving. They are stored on a Linux server, so Perl might be better suited for the task, it's just that I got a method to check for bad images already written in Java. Don't really want to try and reimplement it. That and Perl is yukky and I try to stay away from it when possible. EDIT: I'm an idiot. I missed the method listFiles(filter) in the File class. Something about posting a question here lets me figure out the answer in 5 minutes. lamentable dustman fucked around with this message at 16:59 on Sep 26, 2008 |
# ¿ Sep 26, 2008 16:44 |
|
Boz0r posted:I've been learning to write code in BlueJ, but it's poo poo. What IDE should I get instead? Didn't know that was still out, used that back when I took my first programming class in college (used C++ during HS, Clemson taught Java). Eclipse and Netbeans are the two best free ones. Lot of people like IntelliJ IDEA, never used it but you have to pay for it. Fore the most part I develop with Eclipse but have been playing around with Netbeans 6.5 Beta because of the improved webservices and groovy support.
|
# ¿ Sep 29, 2008 16:42 |
|
sonic bed head posted:You need to use this.name and this.salary to change those variables in your increase/decrease methods. Thought that at first, but it actually is a problem with integer math. He is passing a into into the increase/decrease functions then dividing by 100. Sarah Sherman: in the declartion, change it from "int percent" to "double percent" to fix it. In any language that supports types you get to have fun with integer math. You think (Percent/100) will return .1 or whatever because you are taking decimal points for granted. Because Percent is declared as an integer Java will treat the product of the division function as a integer as well and that means chomping off the decimal point. So .5 becomes 0, 1.9 becomes 1, ect. Either make percent floating point or cast it to double by placing (double) in front of it. code:
|
# ¿ Sep 29, 2008 20:02 |
|
Sarah Sherman posted:^^Ah, this seemed to have fixed it. Thanks! The keyword 'this' tells java you mean to change the object's global variable. If you use the same variable name in a method Java assumes the the method variable is not the same as the global. For example from some code I am looking at: code:
For more detail: http://java.sun.com/docs/books/tutorial/java/javaOO/thiskey.html
|
# ¿ Sep 29, 2008 20:11 |
|
Edit: Dumb poo poo, should pay attention what I'm doing. You were doing it right. Also what Incoherence said, that is why you are only getting 4 elements back I think. lamentable dustman fucked around with this message at 19:55 on Oct 1, 2008 |
# ¿ Oct 1, 2008 19:33 |
|
Anyone know any good mapping library out there for java? For a project at work I'm going to feed some longitude/latitude/height data along with other data for that point, say air temperature. Going to want graph the data out as a topography, both 2D and 3D. Think something that looks like a dobbler radar. Really doubt there is anything out there, just thought I would give it a shot.
|
# ¿ Oct 22, 2008 04:47 |
|
sonic bed head posted:"".equals( str ) is NullPointer proof though, isn't it? Yea because "" isn't technically null, it's just empty.
|
# ¿ Oct 22, 2008 14:37 |
|
Trying to generate some images in Java. To visualize what the grid would look like:code:
I would eventually like to make it 3D for an isometric view but that isn't required and down the road.
|
# ¿ Oct 24, 2008 17:08 |
|
Yea, that looks like more what I need to do. Didn't occur to me that I could do that. I've only used BufferedImages to modify existing images, never to create one from scratch.
|
# ¿ Oct 24, 2008 17:41 |
|
Mill Town posted:Yeah, it's quite easy to create a new BufferedImage and just loop through all the pixels, filling them in with what you want. Something like this: Sweet, thanks man, looks like that is exactly what I needed to see. It looks like the line: code:
code:
code:
|
# ¿ Oct 27, 2008 14:25 |
|
He was saying to do that so you can figure out the global variable names better. Once you add the jar to the classpath of your project it should show up in the left pane. You should be able to explore the classes inside it. Once you import one of those classes to a new class you can use the code completion feature to get more meaningful global variable names. You obviously won't get the local names though. Just out of curiosity, how do they expect you to fix the bug without the original source code? Doesn't make sense.
|
# ¿ Nov 12, 2008 17:25 |
|
Kinda sorta. It's in between a scripting language and a full compile I guess. Java is compile down to byte code. This does make decompiling easier but not 100% accurate. Comments are striped of course and I'm sure other optimizations are performed on the code. Variable names are changed to become more machine friendly. The decompiler makes due with these by assigning the variables the same name as the class name.
|
# ¿ Nov 12, 2008 18:59 |
|
Actually, I might be wrong about the decompiler, looked at some of my code compiled code with DJ and it mostly matches the java code. So I dunno, when I've used it before it's always given me code that looks like "Object object1 = new Object()" As for the applet, it runs in a browser right? What does the HTML code call? Should look something like this: code:
|
# ¿ Nov 12, 2008 19:20 |
|
Decompile all the code, add it to an Eclipse project, right click on 'com.appname' and choose 'run as applet'. Not sure how much help it'll be without the original source code.
|
# ¿ Nov 12, 2008 19:28 |
|
Fruit Smoothies posted:I now get "applet not initialised" ugh, lots of things cause that. Usually has to do with the classpath isn't matching up. Also you try passing the parameter you have to it. Right click on the class and choose run configurations. There is a tab for parameters.
|
# ¿ Nov 12, 2008 19:45 |
|
Eclipse makes that file when it runs an Applet automatically. Generates the HTML to embed in a page or something, I always ignore it. No idea why it can't be read though. Is it even getting written? Permissions problem?
|
# ¿ Nov 12, 2008 20:25 |
|
dancavallaro posted:When I'm done with a project in Eclipse, is there an easy/automated way to deploy the project as an executable JAR file? Or I guess I'm just asking, what's the best way to deploy an Eclipse project as an executable application? Right click on the project, choose export, expand Java. You'll have the option for JAR and executable JAR.
|
# ¿ Nov 13, 2008 15:02 |
|
Google says to use a stream instead of File.code:
|
# ¿ Nov 13, 2008 18:52 |
|
RGB is already hex. FF = 255 F0 = 240 If it is really important extend the class or something and make a function to take a string or hex number, parse to separate the color pairs, make them ints, and pass to the real setColor (or whatever it is).
|
# ¿ Dec 19, 2008 06:21 |
|
So I've been working on this applet/servlet combo for a while now. The applet communicates with a servlet that collects data and sends it back to the applet via HttpsURLConnection. I'm using an unsigned cert for now as everything is on my dev machine. Everything was running good till I updated the Java version today and the applet started throwing "java.security.AccessControlException: access denied (java.net.SocketPermission localhost:8443 connect,resolve) So far I've tried editing my java.policies file, disabling my firewall (though everything is local). I don't think it has to do with my cert as I can reach https://localhost:8443/, everything is encrypted. Also, when I first started using SSL with the applet I was getting different, more descriptive errors till I fixed it. The code where it gets thrown is basically this: code:
edit: does the applet have to be signed or something? I'm not modifying anytihng on the client's system but I am connecting to something out of it's domain I guess. Like I said, it worked fine with 1.5 so I guess security is tighter in 1.6 lamentable dustman fucked around with this message at 23:03 on Dec 29, 2008 |
# ¿ Dec 29, 2008 22:57 |
|
Ensign Expendable posted:You're missing a variable name. Shouldn't it be whoops, it is there in the real code. The code is on a secure system that can't reach the internet so I couldn't c/p it. Eclipse would of caught that pretty fast anyways.
|
# ¿ Dec 30, 2008 00:59 |
|
I figured it out, it was an issue with java versions. I've been using the Eclipse plugin 'Web Tools Platform' which had a section called 'facets' that needed the compiler level changed in. I was getting an error from it apparently but didn't notice, it looked like it was compiling anyways.
|
# ¿ Dec 30, 2008 16:10 |
|
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 |
|
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 |
|
what application server are you running? anything in the logs?
|
# ¿ Jan 7, 2009 03:06 |
|
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 |
|
Jmcrofts posted:I'm really new to Java, and am learning it for a CS class. I installed the Java SDK on my home computer, and whenever I try to run my compiled code through the command prompt I get an error message that says Going to need more info like what command are you running to compile? javac MyClass.java ? Are you using packages or any external libraries?
|
# ¿ Jan 22, 2009 22:01 |
|
Citanu541 posted:Well, this is really embarassing but I can not find any logical answer to my problem in my textbook, nor google. I don't think I so much have a problem with You have several problems with the code. The method call getContentPane() is in JApplet not Applet so instead of "extends Applet" it should be "extends JApplet" JApplet is part of Swing, Applet is part of awt. Next you have "JLabel greeting = new Label("Who are you?");" Notice that your types are mismatched. Either make them both JLable or Lable. Last issue is that your constructor for the Font object is wrong. Look here for the correct constructors http://java.sun.com/javase/6/docs/api/java/awt/Font.html About the main class problem, you don't need one when making an applet or JFrame or whatever. I don't use netbeans so I'm not sure how it is there but in Eclipse they give you the option of "Run as applet" instead of "Run as application." Bellow is probally what you wanted your code to look like code:
lamentable dustman fucked around with this message at 23:00 on Jan 23, 2009 |
# ¿ Jan 23, 2009 22:56 |
|
Citanu541 posted:Ah, thank you. I started debugging the obvious, but still ran into the no main class problem. I didn't realize all my syntax errors before posting that, but as I said, I didn't think the code was the problem. When every inch of the code is underlined in red, you start to feel the problem is else where. I launched NetBeans and had a look. When you create a project in NetBeans it makes a 'Main.java' class. You should probably just delete that. In the right click on the java file in the left pane (or hit shift+F6) you have the option to run the code. It launches just fine in the applet viewer.
|
# ¿ Jan 23, 2009 23:14 |
|
I'm having an issue with having javascript communicating with a java applet I'm writing. The poo poo was working fine 3 weeks ago and apparently I've changed some things to break. I got the code cut down to bellow to test.code:
code:
In the full applet this updates a map which flashes for a split second before going back to the initial state like this example is showing. Any ideas why this is happening? It was working fine before.
|
# ¿ Jan 26, 2009 18:48 |
|
gently caress, just realized it is because I'm using a form tag and that is causing the whole page to reload. Took it out and it worked properly..... I had to remake the page after my workstation was reloaded and I forgot to back up that part.... that loving poo poo cost me over 6 hours of time....
|
# ¿ Jan 26, 2009 19:10 |
|
rjmccall posted:Right, and "hop" before "hot", and "hot" before "hottentot". Something worth noting: compareTo's algorithm is based purely on the numeric values of characters, and the capital (English) letters happen to all be numerically less than the lowercase letters, so it will also put "Hot" before "abracadabra" but chances are good that your professor will be overjoyed if you can manage the if statements and certainly will not quibble over case-sensitivity. compareToIgnoreCase() exists for that reason
|
# ¿ Feb 4, 2009 05:37 |
|
Sour Fish posted:I have a null pointer exception and can't for the life of me figure out what is wrong, could someone please help? Sysout the string 'line' or something. It is probally null or ""
|
# ¿ Feb 6, 2009 01:53 |
|
|
# ¿ Mar 28, 2024 13:18 |
|
Logostomp posted:I've got the input working. Here's the question. Not really seeing a question (or why this is even hard) here but make 5 stacks or something. Push the input into the correct stack when read in. Count the data structure for the output.
|
# ¿ Feb 12, 2009 01:38 |