|
EDIT: I have thoroughly poo poo up this post to the point where it is just entirely out of control and I should figure out what I am trying to ask before I actually post a question.
Save Russian Jews fucked around with this message at 07:10 on Jan 28, 2012 |
# ? Jan 28, 2012 06:41 |
|
|
# ? Jun 3, 2024 02:23 |
|
I'm working on a program to calculate Pascal's Triangle up to 16 rows, and then print it out as a (mostly) perfect isosceles triangle. I'm having trouble coding a formula to do this cleanly though, and the only appearant solution I can think of is to write a method that will print each line of the triangle with unique directions for spacing. This is what I have so far:code:
code:
|
# ? Jan 28, 2012 22:03 |
|
code:
|
# ? Jan 28, 2012 22:19 |
|
DholmbladRU posted:
Your class is called 'homeObj', and your last line is 'homeObj.<method>', which looks like a static call. The last line should say 'homeObject.setLocation...' instead. Also, class names should start with an upper-case letter in Java. It helps avoid things like this.
|
# ? Jan 28, 2012 22:26 |
|
Kilson posted:Your class is called 'homeObj', and your last line is 'homeObj.<method>', which looks like a static call. The last line should say 'homeObject.setLocation...' instead. thanks... I have been racking my brain over this for a little while. dyslexia at its finest..
|
# ? Jan 28, 2012 22:29 |
|
Kilson posted:Your class is called 'homeObj', and your last line is 'homeObj.<method>', which looks like a static call. The last line should say 'homeObject.setLocation...' instead. ClassName variableName (or variable_name, but this is awkward) CONSTANT_NAME
|
# ? Jan 29, 2012 00:43 |
|
Harold Ramis Drugs posted:I'm working on a program to calculate Pascal's Triangle up to 16 rows, and then print it out as a (mostly) perfect isosceles triangle. I'm having trouble coding a formula to do this cleanly though, and the only appearant solution I can think of is to write a method that will print each line of the triangle with unique directions for spacing. This is what I have so far:
|
# ? Jan 29, 2012 01:32 |
|
Harold Ramis Drugs posted:If you guys can give me any pointers on how to format my printing so that the correct numbers line up, I would be greatly appreciative. Thanks Make it look like this: code:
|
# ? Jan 29, 2012 02:57 |
|
I am developing a small web app in jsp. All my dev is done with eclipse/tom cat. Well I have created all my java code for the back end, and now it is on to learn how to make a jsp page(first time). Well I am trying to create an instance of a java class on a jsp page. Where do I place this inside the eclipse directories? I saw somewhere in wen-inf/lib but that didnt seem to work. trying to import with something like this <%@page import="myClass.java"%> I was able to import classes which were in the standard java package with the above code. Is there some additional step I am missing other than placing the .java file in the director? code:
<%@ page import="readXMLFile.java" %> I did just find this resource online: http://www.coderanch.com/t/288534/JSP/java/importing-class-file-jsp I will try it when I get home. DholmbladRU fucked around with this message at 15:26 on Jan 30, 2012 |
# ? Jan 30, 2012 15:17 |
|
Um, yeah. Java is a compiled language, you need to compile the .java file to a .class file before you can use it. The Java code that's contained in the JSP files is compiled automatically by Tomcat, but regular Java files need compiling before use.
|
# ? Jan 30, 2012 15:29 |
|
DholmbladRU posted:words... What are servlets? http://en.wikipedia.org/wiki/Java_Servlet Therefore, when you put in a statement like <%@page import...%> that becomes just an import myClass; in the generated servlet. And you already know that you can't import a .java file, just a class (compiled one). One small piece of advice: avoid if you can java code in a jsp. Is just bad practice. Use tags (JSTL for example) instead. Additionally, avoid logic in the JSP, use it just to present data. It will come handy if your application grows. If this is a homework though...don't worry about any of this, just do whatever your professor told you.
|
# ? Jan 30, 2012 15:40 |
|
rhag posted:JSP's are just servlets, think of them this way. They get compiled into servlets by your application server (tomcat, jboss, etc.) . Once I understand how to import my java classes(thank you for the above info) I will be calling a controler java class which will take the use input and pass it to some logic class, which will then return an array to be displayed on a "results".jsp. It isnt for homework. Thank you for the information.
|
# ? Jan 30, 2012 16:07 |
|
I have one of these and at my school we're writing a synthesizer, and I'd like to use this thing to trigger it. (How) can I access information from it in Java?
|
# ? Jan 30, 2012 21:38 |
|
rhag posted:words code:
|
# ? Jan 31, 2012 04:36 |
|
DholmbladRU posted:
Take the .class off the end. Also spell 'classes' correctly in your package name.
|
# ? Jan 31, 2012 04:59 |
|
Contra Duck posted:Take the .class off the end. Also spell 'classes' correctly in your package name. ah sorry, was typing quickly into the forums. have tried with and without the .classes with code:
|
# ? Jan 31, 2012 05:56 |
|
DholmbladRU posted:ah sorry, was typing quickly into the forums. have tried with and without the .classes Is readXMLFile in a jar? If so what package is it in? build.classes dosen't sound like a package but the root of your compile directory. Also follow the Java style guide. Classes start with a capital letter.
|
# ? Jan 31, 2012 06:30 |
|
donglelord posted:Is readXMLFile in a jar? If so what package is it in? build.classes dosen't sound like a package but the root of your compile directory. no, build and classes are directories in the workspace folder. readxmlfile is not a jar file, it is a .java class in my dynamic web project. I found the .class files in the workspace folder.
|
# ? Jan 31, 2012 14:34 |
|
When you use "<@ page import", you're not importing a file, you're importing a java class. If you open the .java file, it will say "package x.y.z" at the top somewhere. Your import should look like 'import="x.y.z.<classname>"'.
|
# ? Jan 31, 2012 18:50 |
|
Kilson posted:When you use "<@ page import", you're not importing a file, you're importing a java class. If you open the .java file, it will say "package x.y.z" at the top somewhere. Your import should look like 'import="x.y.z.<classname>"'. if I do "import=build.classes.readXMLFile" it states that the import build cannot be fond. readxmlFile is a .class file found in the directory in my previous comm.
|
# ? Jan 31, 2012 19:50 |
|
I need a good Spring/Hibernate textbook that walks through Spring MVC project setup etc. I've used Spring a lot but never done a complete greenfield project setup which I think is a pretty gaping hole in my knowledge.
|
# ? Jan 31, 2012 20:01 |
|
Blacknose posted:I need a good Spring/Hibernate textbook that walks through Spring MVC project setup etc. I've used Spring a lot but never done a complete greenfield project setup which I think is a pretty gaping hole in my knowledge. I don't think you need a textbook to do this, it's really not that hard especially with annotations in 3.0+. I would just make a few simple hello world-ish projects to get used to all the initial boilerplate web.xml stuff and some of the gotchas with dispatcherservlet and you should be fine.
|
# ? Jan 31, 2012 20:28 |
|
DholmbladRU posted:if I do "import=build.classes.readXMLFile" it states that the import build cannot be fond. readxmlFile is a .class file found in the directory in my previous comm. This is because build.classes is not your package path. Your package path is com.company.division.project.reaadxmlfile or whatever. It will be at the very top of the .class file as "package whatever". If you don't declair a package just have import readxmlfile in your jsp page
|
# ? Jan 31, 2012 21:07 |
|
DholmbladRU posted:if I do "import=build.classes.readXMLFile" it states that the import build cannot be fond. readxmlFile is a .class file found in the directory in my previous comm. Look in your .java file, the first few lines should look something like this: code:
code:
|
# ? Jan 31, 2012 21:28 |
|
TRex EaterofCars posted:I don't think you need a textbook to do this, it's really not that hard especially with annotations in 3.0+. I would just make a few simple hello world-ish projects to get used to all the initial boilerplate web.xml stuff and some of the gotchas with dispatcherservlet and you should be fine. I guess you're right. I have used Spring quite a lot, it's mainly just setup and some of the newer features. I guess I'll make some kind of noddy little webapp and see how it goes. Now if I can just stop getting distracted by Scala...
|
# ? Jan 31, 2012 21:38 |
|
cenzo posted:words These .java files were created in this dynamic web page project in Eclipse. There is no "package" declaration at the top. They do fall under the "default package" in the Java Resources/src, can I call this default package? code:
http://img.photobucket.com/albums/v422/dholmblad/t1.png As you can see the java classes I have written are in src>xml(package I just created). The jsp file is WebContent. Still unable to import these files:( DholmbladRU fucked around with this message at 05:08 on Feb 1, 2012 |
# ? Feb 1, 2012 03:40 |
|
The Java files aren't compiling. You can tell because the J in the icon isn't filled in. That means your folder called 'src' isn't set up as the source folder in eclipse. Looks like you set src/XML as your source folder. You also have build/classes set as a source folder which isn't right lamentable dustman fucked around with this message at 06:38 on Feb 1, 2012 |
# ? Feb 1, 2012 06:33 |
|
donglelord posted:The Java files aren't compiling. You can tell because the J in the icon isn't filled in. That means your folder called 'src' isn't set up as the source folder in eclipse. Looks like you set src/XML as your source folder. src is now the source folder, and the J icon is filled in on all of the java classes. Java Resources>src>(default package)>all the java files How do I import one of these classes into jsp, it is really killing me. Seems so simple I just cant get it right.
|
# ? Feb 2, 2012 03:28 |
|
You really should put your files into a package of some kind. Trycode:
code:
|
# ? Feb 2, 2012 03:42 |
|
This might be an unanswerable question, but does anyone know what percentage of users have upgraded to JRE 1.7, as opposed to staying with the latest 1.6 update? I mean, if I'm writing to something with JDK 1.7, how likely do you guys think I am going to be getting people coming back to me with some issue?
|
# ? Feb 2, 2012 04:24 |
|
The Selling Wizard posted:I mean, if I'm writing to something with JDK 1.7, how likely do you guys think I am going to be getting people coming back to me with some issue?
|
# ? Feb 2, 2012 04:29 |
|
The Selling Wizard posted:This might be an unanswerable question, but does anyone know what percentage of users have upgraded to JRE 1.7, as opposed to staying with the latest 1.6 update? The amount of people who like Java applets is about the same amount of people who have upgraded to 1.7
|
# ? Feb 2, 2012 04:31 |
|
TRex EaterofCars posted:You really should put your files into a package of some kind. Try I am pretty sure that worked, thank you so much.
|
# ? Feb 2, 2012 04:33 |
|
I figured it was something obvious like that. Thank you.
|
# ? Feb 2, 2012 04:38 |
|
This is Struts 2 specific - but <html:select /> won't apply the error css class or style when I add addFieldError(String elementName, String errorText). Google has failed me and all I've been able to find is discussion about the addFieldError method in general. We don't have any special tags to further handle the struts tags in case of an error. Edit: figured it out. html:select needs cssErrorClass to be set. Which for some reason is not an attribute that's required for textfields / areas / etc. geeves fucked around with this message at 17:23 on Feb 2, 2012 |
# ? Feb 2, 2012 16:19 |
|
I've got an object that has two private members: a String and an int. I've got a container of these objects and I need to sort them in two different ways: alphabetically using the String, and numerically using the int. Implementing Comparable would only allow me to do one of these. I recall (possibly from other languages I've done) that you can define the comparison function to use during the call to sort the container (sort of like an in-line method declaration). What is this structure called, and can someone point me to a good example of it?
|
# ? Feb 3, 2012 15:10 |
|
You're thinking of a comparator. Here's the learning trail. Edit: and if you really want to define it inline you'll use the Anonymous Class facility: http://docstore.mik.ua/orelly/java-ent/jnut/ch03_12.htm
|
# ? Feb 3, 2012 15:15 |
|
I'm building a little something for school where a system has a number of different types of accounts (eg: admins, mods, shmoes) and my wish is to create a default 'Account' class and then to extend it to the various other classes, but I think I may be cornering myself by being too eager to use inheritance. Question: If my Account class implements serializable so that I can write Account files, would my read/write methods in the parent class be properly inherited by the subclasses? ie, reading an Account object from its file in the parent method would require typing the object as an Account - so would typing a Shmoe as an Account destroy his attributes which are distinct to Shmoes? eg, from the 'Account' class, code:
|
# ? Feb 3, 2012 21:21 |
|
You may want to consider an account as, well, just an account that has f.ex, a username and a role or a list of roles, where a role is an admin, a mod, or a schmoe (use inheritance here). Then serializing an account and determining which actual role objects need to be instantiated is more straightforward.
|
# ? Feb 3, 2012 22:38 |
|
|
# ? Jun 3, 2024 02:23 |
|
I am having a hard time getting images to show up frm a jsp pagecode:
code:
page source ends up being code:
when displayed in browser, which seems correct DholmbladRU fucked around with this message at 17:04 on Feb 5, 2012 |
# ? Feb 4, 2012 21:24 |