Click here to Skip to main content
       

Java

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: List in javamemberjschell18-May-12 12:21 
Create another list and add each result to it.
AnswerRe: List in javamemberTorstenH.19-May-12 1:02 
The List Interace - Tutorial @ oracle.com[^]
regards Torsten
When I'm not working

AnswerRe: List in javamemberCodingLover28-May-12 18:00 
Are you trying to keep the results on same List? Because I wonder, if you have already create a List and store data, you should not stuck with creating another List and store the results in that new List. Could you please clarify, so I can help you further if required. Smile | :)
I appreciate your help all the time...
CodingLover Smile | :)

QuestionGlobal Variable - Problem in diff. session.memberNanda_MR16-May-12 22:04 
Hi to all,
 
public class xyz {
 
public static int gUserID = 1;
 
}
 
When 1st user Login gUserID value is = 5
and second user login gUserID value is = 7
 
Problem is 1st user refresh or re-direct to another page gUserID is changing to 7.
 
How to set Global variable for session or any solution to above problem.
 
Thanks.
AnswerRe: Global Variable - Problem in diff. session.memberNagy Vilmos16-May-12 22:27 
How is the variable being updated?
 
The single variable is used by every instance of the class. If you want each instance to have a userId then you need something like this:
 
public class Test {
    // note it's private! This stop anything else from changing it.
    private static int nextUserId = 1;
 
    private int userId;
    public Test() {
        this.userId = Test.nextUserId++;
    }
 
    public int getUserId() {
        return this.userId;
    }
}


Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

GeneralRe: Global Variable - Problem in diff. session.memberNanda_MR16-May-12 22:40 
Hi Nagy Vilmos,
 
I m update gUserID from database. As soon as login to application. I m setting corresponding user id to that variable and I m utilizing that variable in complete project as global variable.
 
here I m facing problem. As soon as 2nd person login The Value is reset (2nd user id is updating).
 
I m trying your method now Thanks.
GeneralRe: Global Variable - Problem in diff. session.memberNagy Vilmos16-May-12 23:26 
Now I understand.
 

You have an instance for each user, so the variable must not be static. If it is possible to set the value in the constructor, then that is the best thing because you can make the member variable final and so it cannot be changed.
 

It is strongly advised to not expose member variables outside the class, it is ALWAYS better to use in this case a method; as I used in my example. If the variable is final, then you can to some extent relax the rule as there is no way it can be changed; but this is normally reserved for constants.


Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

GeneralRe: Global Variable - Problem in diff. session.memberTorstenH.17-May-12 1:17 
my +5.
 
I would like to point out that the UserID should also be an automatically created number that the user object should not modify - it's hard to identify the data otherwise.
regards Torsten
When I'm not working

AnswerRe: Global Variable - Problem in diff. session.memberjschell17-May-12 11:18 
Nanda_MR wrote:
How to set Global variable for session

 
You start by researching how to handle session data in a web application.
QuestionGet the project path using Java.memberhansoctantan16-May-12 0:39 
Hi,
 
I have a problem on getting the project path of a web application.
Reason on getting the project path is I'm uploading a PDF Files to the project path so that I can open it to the browser, I'm hoping to do this http://localhost:8080/PDFviewer/UploadedFiles/sample.pdf.
 
I have found something in the Internet but the path is not in my project path
getServletContext().getRealPath("/");
My project path is D:\Java\Java Web Projects\PDFviewer but the above code is giving me D:\Java\Java Web Projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\PDFviewer
 
Can anybody please suggest a way of getting the application path in java.
 
Thanks... Thumbs Up | :thumbsup:
AnswerRe: Get the project path using Java.memberTorstenH.16-May-12 0:59 
The path the system gives you is correct, because the web server is placed in the wtpwebapps folder.
 
Try to deploy it and see if the path comes up correct on a test system. I assume so.
regards Torsten
When I'm not working

GeneralRe: Get the project path using Java.memberhansoctantan16-May-12 4:21 
Thank you very much it work perfectly what I expected... Laugh | :laugh:
 
Even if its not in my Eclipse Web Project it can view the pdf.
 
Thumbs Up | :thumbsup: Thumbs Up | :thumbsup: Thumbs Up | :thumbsup: Thumbs Up | :thumbsup: Thumbs Up | :thumbsup:
GeneralRe: Get the project path using Java.memberTorstenH.17-May-12 1:18 
you're welcome.
 
This can be confusing, one is never secure to not struggle on such things.
regards Torsten
When I'm not working

GeneralRe: Get the project path using Java.memberhansoctantan18-May-12 0:01 
yes, I'm really confused...
I can't see the uploaded files in my Eclipse App..
Questionconvert video to bytememberjiojo15-May-12 23:30 
want to convert the content of video to byte in java could any body help me to do that?
AnswerRe: convert video to bytememberTorstenH.16-May-12 0:56 
convert video to byte[^]
 
asking once should be enough.
regards Torsten
When I'm not working

QuestionVideo Conferencing using Java Media Framewrok and Servlet.memberSolanki Savan15-May-12 23:09 
Please anybody help me to implement Video Conferencing in my project Virtual Classroom using Java Media Framework and servlet.
Thanks

AnswerRe: Video Conferencing using Java Media Framewrok and Servlet.memberTorstenH.16-May-12 1:03 
Chance 1: big buget. Call me!
 
Chance 2: You might want to read this: Documentation on JMF[^]
regards Torsten
When I'm not working

QuestionOverloading ConceptsmemberAyyanar G11-May-12 3:27 
What is exact diff. between the operator,constructor and method overloading.....Give some examples also....Confused | :confused:
AnswerRe: Overloading ConceptsmemberTorstenH.11-May-12 3:58 
Classes and Objects[^]
 
Overriding Methods[^]
 
I can recommend to by a good book explaining the basics. And I can recommend to read them even one has already worked in the business( kind of back to roots)
regards Torsten
When I'm not working

Questionproblem of a deployment in tomcat servermemberBouali tayeb10-May-12 0:04 
when i want to deploy my application in tomcat server it can't and this is the error message
 

 
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
Undeploying ...
undeploy?path=/Mango
OK - Application non-déployée pour le chemin de contexte /Mango
In-place deployment at D:\PFE\Mango\build\web
deploy?config=file%3A%2FC%3A%2FUsers%2FBouali%2FAppData%2FLocal%2FTemp%2Fcontext4268238340729989227.xml&path=/Mango
FAIL - Deployed application at context path /Mango but context failed to start
D:\PFE\Mango\nbproject\build-impl.xml:847: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 2 seconds)
I await your answers in short delays. thank you in advance
AnswerRe: problem of a deployment in tomcat servermemberGerben Jongerius10-May-12 9:20 
The build script is already telling you what you should be doing next. Locate and look into the catalina.out file for more details as to why the web app failed to start.
 
As to where the catalina log files are, that depends greatly on what type of Tomcat install this is. If it's integrated in Netbeans then it's located in the .netbeans/7.1.1/apache-tomcat/logs.
 
If it is a debian / ubuntu based linux its found under /var/log/tomcat
 
In either case the catalina log will show the root cause of the failure to start. But it's most likely something in the web.xml that is wrong.
QuestionCloud Computing For Agent Based Urban Transportation Systemmembercloudagent9-May-12 8:25 
Hello there,
Above subject is my project topic.
So i need help for executing it properly on my Windows XP system.
 
Installed Software.
 
1.JDK
2.Tomcat
 
But i dont know how compile the code in eclipse.
 
Plz help me out.
AnswerRe: Cloud Computing For Agent Based Urban Transportation SystemmvpRichard MacCutchan9-May-12 9:04 
cloudagent wrote:
Plz help me out.

Read the eclipse help pages which explain how to create and build a project; it is really quite simple.
When you have a more specific technical question feel free to come back for further help.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

AnswerRe: Cloud Computing For Agent Based Urban Transportation SystemmemberTorstenH.9-May-12 19:37 
http://tomcat.apache.org/tomcat-4.0-doc/appdev/deployment.html[^]
 
here you go. You need to deploy your project as a *.WAR file and then bring it to the tomcat. Don't forget to register it there.
regards Torsten
When I'm not working

AnswerRe: Cloud Computing For Agent Based Urban Transportation Systemmemberjschell10-May-12 9:33 
cloudagent wrote:
But i dont know how compile the code in eclipse.

 
Hopefully either you have more than a beginner level of programming experience in java or have at least a mid-level experience in programming something like C++ or C#.
 
Otherwise in terms of what one might suppose "project topic" means you have bitten off more than you can chew.
 
If you do have that then it might help to note that you don't need eclipse to use tomcat.
QuestionEnrich resultmemberRORY178-May-12 9:09 
i have ontology and i made a query on it in java with jena ,lets say that i search for "car" my request is how i retrieve all relations that related with "car"
note:i used wordnet into java but the result is so poor
AnswerRe: Enrich resultmemberTorstenH.8-May-12 18:56 
Th project Jena Ontology API[^] has a documentation[^].
 
I bet your answer is in there.
regards Torsten
When I'm not working

GeneralRe: Enrich resultmemberRORY179-May-12 10:13 
in documentation I found code describe all the ontology in java but what i want is when i ask for "car" the result be all relations that related to "car"
QuestionScreen scrapping in javamemberMember 76606358-May-12 1:35 
Hi All,
 
I have a problem which is bit tricky for me. The problem is - A table is get display on my screen by another application. I have no rights to access that application. This table is also get refreshed in a time interval of 5 to 10 seconds. Now my problem is to fetch the data from the table displayed on the screen and prepare a separate report for every time interval.
 
So please help me to write the api for desired functionality.
 
Thanks in advance.
 
rks
AnswerRe: Screen scrapping in javamemberBobJanova8-May-12 3:08 
You will have to interact with the host operating system for this. Java is really the wrong tool for the job.
AnswerRe: Screen scrapping in javamemberjschell8-May-12 13:49 
Member 7660635 wrote:
So please help me to write the api for desired functionality.

 
Easy - you can't as stated.
 
Member 7660635 wrote:
I have no rights to access that application.

 
Did you actually mean that you do not have the ability to change it? As stated you have no way to get to the application at all, which means nothing is possible.
 
Presuming that you can in fact access the running application then to get to the data depends on the specifics of the application. However in general it would require an OS specific app, so not java, but instead a C/C++ app (which you might or might not be able to find free/shareware/commercial.)
AnswerRe: Screen scrapping in javamemberTorstenH.8-May-12 18:52 
what kind of "application with a table" is that??
What language is the other application written in?
 
There might be a reason for that you are not allowed to access - copyright for example is a pretty good one. In that case one has do deny the request.
regards Torsten
When I'm not working

AnswerRe: Screen scrapping in java [modified]memberGeorge Stragand17-Jun-12 3:05 
If the "application" is HTML, why not use the Jericho HTML parser (http://jericho.htmlparser.net/docs/index.html) to retrieve the HTML


modified 19-Jun-12 22:36pm.

QuestionMethod in Javamembertrongduy7-May-12 4:21 
I have a question,please help me,how can i distinguish and declare 1 method and 1 object in java?
 
Example:static void main(String[]args)throws Exception{
public static Test(int a){
}
}
 
Why i have to declare(int a)?
I am a newbie and please help me.
AnswerRe: Method in Javamemberekolis7-May-12 5:27 
Why are you trying to declare one method (Test) inside of another method (main)? I don't think Java supports that...
 
As for "int a", that's an argument to the method (something that gets passed in as input). So if you wanted to call your Test method, you would have to pass in an int, and inside the method you would refer to that int as a.
AnswerRe: Method in Javamemberkoropatva7-May-12 20:38 
on you [age you have somethink like this:
 
public class nameOfYouClass{
static void main(String[]args)throws Exception{
}
}
 
If ou want create new class you may create new class write somethink like this:
public class nameOfYouClass{
static void main(String[]args)throws Exception{
nameOfYouNewClass nameOf = new nameOfYouNewClass();
nameOf.newMethod();
}
}
 
class nameOfYouNewClass{
public void newMethod(){
System.out.println("Hello Workd!!");
}
}
 
and you will create new Object with method called newMethod.
 
If you want use class nameOfYouNewClass just create this class in the you main function. And you may use methods from this class(object)
AnswerRe: Method in JavamvpRichard MacCutchan7-May-12 22:00 
Work your way through these tutorials[^], and all your questions will be answered.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

QuestionHow to remove Duplicates in ArrayListmemberB.Bryce7-May-12 4:02 
I have this the code below:
 
I used this code based in HashSet to remove duplicates but does not work:
public static <Enterprise> void removeDuplicates(ArrayList<Enterprise> list) {
HashSet<Enterprise> h = new HashSet<Enterprise>(list);
        list.clear();
        list.addAll(h);
    }
 
public static void main(String args[]) {
ArrayList<Enterprise> array = new ArrayList<Enterprise>();
array.add(new Enterprise("Micro System", 2001));
        array.add(new Enterprise("Delta Force", 1980));
        array.add(new Enterprise("Micro System", 2001));
        array.add(new Enterprise("Golden Mayer", 1781));
 
        removeDuplicates(array);
 
        for (Enterprise item : array) {
            System.out.println(item);
        }
    }
}
 

public class Enterprise {
 
    private String name;
    private int yearFondation;
 
    public Enterprise(String name, int yearFondation) {
        this.name = name;
        this.yearFondation = yearFondation;
    }
 
    public String getname() {
        return name;
    }
 
    public int getYearFondation() {
        return yearFondation;
    }
 
    public void setname(String name) {
        this.name = name;
    }
 
    public void setYearFondation(int yearFondation) {
        this.yearFondation = yearFondation;
    }
 
    @Override
    public String toString() {
        return "Enterprise : " + name + "   Year of Fondation : " + yearFondation;
    }
}

AnswerRe: How to remove Duplicates in ArrayListmemberekolis7-May-12 5:31 
Enterprise is a class, so when you call
 
array.add(new Enterprise("Micro System", 2001));
 
twice, you are actually adding two different Enterprise objects to array; they just happen to have the same data.
 
If you want the identical objects to be treated as if they were the same object, unfortunately I don't recall how HashSet does the comparisons, but I'm guessing you'll either have to override equals or hashCode on the Enterprise class.
GeneralRe: How to remove Duplicates in ArrayListmemberBobJanova8-May-12 3:09 
It does comparisons with equals and hashCode, yes. And if you override one you should override the other.
AnswerRe: How to remove Duplicates in ArrayListmemberkoropatva7-May-12 20:28 
If you generate hashCode() and equals() in Enterprise class all must works. If you use Eclipse go into Source - > Generate hashCode() and equals()... and Eclipse will generate this code instead of you, if you don't know how to do this.
QuestionEducational Imap clientmemberPinifiux6-May-12 23:17 
Hi People!
 
I search a educational imap client project without api´s.
 
Thanks!
AnswerRe: Educational Imap clientmemberTorstenH.7-May-12 1:07 
For an IMAP email client you'll at least need the JavaMail-API. But that's just a JAR file that you'll have to bind in.
 
Tutorials jGuru: Fundamentals of the JavaMail API[^]
 
Java Mail FAQ from JGuru[^]
 
Those two should guide you pretty well through the process of development.
regards Torsten
When I'm not working

QuestionHashMap... am I doing it wrong? [modified]memberStephen Dycus2-May-12 12:17 
I'm rolling my own text system, or trying to anyways...
 
I cycle through the bitmap to determine the texture coordinates of every character. Then add them to the map via their associated char. Later I cycle through a string to pull the texture coords and add them to the buffer... the coords are correct going in but not pulling out.
 
private HashMap<Character, float[]> glyphs = new HashMap<Character, float[]>();
//cycle bla bla
glyphs.put(c[i], temp);
 

/// later
float temp[] = glyphs.get(a);
 
The array returned is the same one for every char sent to the retrieval function. I must be doing this wrong... any help?
 
EDIT: The coord to be retrieved is the coord of the last thing put into the map.

modified 2-May-12 18:27pm.

AnswerRe: HashMap... am I doing it wrong?memberStephen Dycus2-May-12 12:55 
Figured it out... <.>
 
I wasn't instantiating a new temp each pass. So the last element is stored for every key. Easy fix, just re-instantiate the variable before setting a value and calling put()
GeneralRe: HashMap... am I doing it wrong?memberPeter_in_27802-May-12 13:06 
snap! You got it while I was typing (and taking a phone call....)
 
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.

GeneralRe: HashMap... am I doing it wrong?memberStephen Dycus2-May-12 13:07 
Np, thanks for trying. ^^
AnswerRe: HashMap... am I doing it wrong?memberPeter_in_27802-May-12 13:05 
I can't see the rest of your code, but it smells like you are reusing the same temp, effectively overwriting the same item on every put().
 
Peter
Software rusts. Simon Stephenson, ca 1994.

GeneralRe: HashMap... am I doing it wrong?memberStephen Dycus2-May-12 13:06 
Yup, had just posted that. XD Thank you though ^^

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 18 Jun 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid