masijade 1,351 Industrious Poster Team Colleague Featured Poster

Same concept, but just checking for equality.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you can use it, Arrays.sort and return the last element. Otherwise, save the first value and compare it to the others always saving the larger value and then return that.

What part of all that are you having problems with?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

AFAIK, you can't. Use a JLabel or JTextArea.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Show your code, so we can better understand what you're talking about. Generally speaking though, you do not need a "dynamic array", you need to use your "static array" properly.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A JFrame is a top-level component. It can not be "added" to another. Use a JPanel.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

1) Declare a package. You should never place anything in the "default" package.

2) The classname should be Capitalised.

3) The line you're refereing to makes no sense. First of all I believe you mean println not printIn (the first one is a lowercase L the second one, yours, is an uppercase I). Secondly that's a method and you are using it as a (I don't know what). Thirdly you're declaring it (private, protected, public keywords are only used in declarations) which makes even less sense. Thirdly, no matter what you wanted to do with it, the line is imcomplete (and basically just wrong).

4) You do realise that if (0 < 20) will always be true, right? And, I definately would not want to wear shorts and sandals when the temperature is at least 13 degrees fahrenheit below freezing.

5) And I will assume that you simply haven't even started attempting to get input from the user yet, regardless of what that comment says.

PoovenM commented: Right on par! you're the man :D +2
masijade 1,351 Industrious Poster Team Colleague Featured Poster

That's now how I wanted to do it.

I know iwould have to do this

WriteTxt.setCMYKColorFillF(00, 99, 100, 00);
WriteTxt.showTextAligned(0 ,"Hello", 100, 20, 0f);

WriteTxt.setCMYKColorFillF(00, 00, 00, 00);
WriteTxt.showTextAligned(0 ,"World", 120, 20, 0f);

The problem with setCMYKColorFillF is that u can't specify what text of string you want to change.

It should be like WriteTxt.setCMYKColorFillF(00, 00, 00, 00, "World") or something like that.

Well, I'm sorry. There are a lot of things I don't like, that doesn't mean I don't have to do them. darkagn has it correct, create one of your own. Or, search the library you're using (I don't know which one it is) and see if there is a another method (or simply an overloaded version of the same) that does what you want, if not, as already said, implement a "convenience" method, yourself. If the method your using doesn't allow what you want, directly, then you aren't going to be able change that (you could always suggest an enhancement to whoever produced the library, though).

darkagn commented: well said :) +1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do Hello in red, then world in black.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Is there a question in there somewhere?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is a forum for *nix style Shell Scripts. VB is in a different forum. I have already asked the forums to move this thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

But that is what we are saying. You have not read it completely. The first article also talks about AOT (Ahead Of Time) compilers, which create executables. So, as we said, you have not bothered to completely read the document, or you did not comprehend it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You guys are not going ahead of that post above.You think there is no way to deal with it.

Once again, you have not completely read the articles posted in response. Read all of them completely. We have not said, it cannot be done, we have said, it should not be done. Now, go away, as you are either too lazy to completely read the resources suggested, or are too thick to comprehend them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
Prylar getPrylar(String prylr){
      for (Prylar pro : prylar)
void skapaPrylar(){

symbol : method skapaPryl()

Notice the spelling.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is my whole code, if anyone could spot the problem.Im not sure which line it is but it is an illegal start of expresion "public static void main(String []args){" at the end of the code.
(It is underlined). ^

import java.util.*;
import java.io.*;
import java.lang.*;

class PrylDialog {
   ArrayList<Person> personer=new ArrayList<Person>();

   Scanner scan=new Scanner(System.in);

   String readString(String fraga){
      System.out.print(fraga);
      String str=scan.nextLine();
      return str;
	 }

   int readInt (String fraga){
      for(;;){

	 try{
	    System.out.print(fraga);
	    int x= Integer.parseInt(scan.nextLine());
	    return x;
	 }
	 catch (NumberFormatException e){
	    System.out.println("Fel - skall vara numerisk värde ");
	 }
      }
   }

   Person getPerson(String na){
      for (Person p : personer)
	 if (p.getNamn().equalsIgnoreCase(na))
	    return p;
      return null; 
   }
   Prylar getPrylar(String prylr){
      for (Prylar pro : prylar)
      if (pro.getPrylNamn().equalsIgnoreCase(prylr))
      return pro;
      return null;
      }

    int kommando(){
      for(;;){
	 int option=readInt("\n1 Skapa person\n2 Skapa pryl\n3 Visa alla\n4 Visa rikast\n5 Visa viss person\n6 Börskrasch\n7 Avsluta\n\n Ditt val: ");
	 if (option>=1 && option<=7)
	    return option;
	 else 
	 System.out.println("Felaktig kommando, ska vara 1-7\\n"); 
      }
   }

   void skapaPerson(){
      String namn=readString("Namn: ");;
      if (getPerson(namn)!=null){
	 System.out.println ("Person med namn-"+namn+" finns redan");
	 return;
      }
      Person pers= new Person(namn);
      personer.add(pers);
   }

   void skapaPrylar(){
      String pryl = readString("Vilken sorts pryl: ");
      String namn = readString("Vilken person äger prylen: ");
      Person p=getPerson(namn);
      if (p==null){
	 System.out.println("Det finns inget person som heter "+namn);
	 return;
      }
  
      if (pryl.equalsIgnoreCase("Smycke")){
	 int v=readInt("Vikt: ");
	    int sten=readInt("Antal ädelstenar: ");
	    Smycke sm=new Smycke(pryl, v, sten);
	    getPerson(namn).prylar.add(sm);
  }
         else if (pryl.equalsIgnoreCase("apparater")){
	 int inkop =readInt("Pris: ");
	 int slit=readInt("Värde (1-10): ");
	 if (slit<1 && slit>10)
	    System.out.println("You Wroonnng FOOL!!!");
	 return;
	 Apparater ap= new Apparater(pryl, inkop, slit);
	 getPerson(namn).prylar.add(ap);
       } …
masijade 1,351 Industrious Poster Team Colleague Featured Poster

your

void skapaPrylar(){

method is not closed. add another

}

above the

public static void main ....

line

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So, do you want Java or JavaScript? You seem to be using them interchangeably, which they are not. They are two completely separate things.

And, you are neither opening, nor closing, applications on the client (i.e. through the browser) from the server in either JSP or Servlets. All you are doing to "open" the app is sending the content. The browser is "opening" the app, but it could, depending on its content associations, do something entirely different.

You may, and I stress may, be closing something using JavaScript (although I doubt it), but definately not with Java. And if you claim to be, please post that code, as I do not believe it (except maybe with an Applet with all security policies opened up on the client, which would be possible, but I, if I worked there, would immediately stop working there, if that is the case).

And I do not have to tell you anything. So keep the demand of your last statement to yourself. You have been going on and on about this topic for months now, always insisting on being able to do something that you either cannot, or should not do (at least not the way you think it will work). The one time you actually (I believe by accident) did something right (in simply sending the content of the file to the browser after having set the content type and disposition headers and letting the browser decide how to open it) you …

Ezzaral commented: He just refuses to get it no matter how many times it has been explained. +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Show what you have, and we will help you correct it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

you might want to check if the error is in pryDialog() because to me, your code should not give you an error

That error is a compiler error, and as I have said, it is normally triggered by what came before. I.e. the previous method does not have a closing brace (so you then are effectively trying to declare a method within a method) or the last statement is missing the semicolon (which then means that the method declaration is effectively part of the previous statement) are the two main causes of this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JNI is Java Native Interface. Read the tutorial provided by Sun on that. It allows you to use a native library (on unix an *.so file, on Windoof an *.dll, on other OSes I don't know the extension, off-hand) by writing a small "interface" to "translate" the functions in the library, to Java methods. How you would implement this to get process_ids depends on the library being used.

However, you still will not be able to get process ids of processes running on the machine from which the browser is located from your JSP/Servlet (which I know is still what you're trying to do). I really don't know how often you have to be told, that you cannot control what the the client does, or how it does it, from a JSP/Servlet.

A JSP/Servlet can only affect the server (and that is also limited as well, normally) and deliver content to the client. What the client (i.e. browser) does with that content is completely up to the client and not under your control.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

We need to see what comes directly before the method. That error normally occurrs because you've done something wrong before that, such as not closing a previous method, or forgetting a semicolon on the previous line, etc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just side question masijade, what about stroring data in XML file?

Also a possibility. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

is the keyword public spelled public or Public?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Once again, you are not reading the articles completely.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use Derby/JavaDB in the embedded mode and distribute the empty db with the application.

Or use RandomAccessFile and create your own dbm type DB (I've done this myself, just to try it, and as long as you're not going to get too fancy in your search possibilities, or too expansive in the data, it's not hard to implement.)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See

http://www.daniweb.com/forums/thread101156.html

The asssignment must be due, soon, or something.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Don't do peoples (home)work for them.

Edit: It doesn't help them, in the least.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A Calendar object set to the proper year and month and the getActualMaximum method.

See the API doc for Calendar.

Edit:

But, if you want (for whatever reason) to figure it out the "old-fashioned way" then convert the following into a short algorithm.

Feb has 29 days in every year evenly divisible by 4, excpet when the year is also evenly divisble by 100, unless the year is also evenly divisble by 400.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Attempt #2.

http://www.daniweb.com/forums/thread101560.html

Please stick with one thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the last three words of my last post.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API docs for String. The methods you're interested in are
1) substring, combined with indexOf
or
2) replaceFirst / replaceAll

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I still don't know what you mean by "instance id". Do you mean "process id". If so, are you attempting to find out the process ids on the client using JSP? If so, forget it again.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read in the entire String, then lop-off what you don't need.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have no idea what you mean.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JavaScript != Java

Have already asked the admins to move this thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use a JFrame only for the "main" dialog. Use a JDialog (or better yet a JOptionPane) for the "popups". Read the API docs for JDialog and JOptionPane (and JOptionPane and its "finished" methods are the way to go here).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.

iamthwee commented: Damn right! +13
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ha. ;-)

Din't really look at the class name. These classpath questions (at least because of other forums) have simply become knee-jerk reactions. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Another person who doesn't bother to actually read the thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

J2ME (Micro/Mobile Edition) is a limited version of the J2SE (Standard Edition) and definately will not have anything that first available in the J2EE (Enterprise Edition).

See http://java.sun.com/javame/reference/apis.jsp#api and select the link for the appropriate version to see the API docs, and find out what is available.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You haven't included the jarfile containing the Oracle JDBC Driver on the classpath.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A counter?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

But there was a resolution. did you see posts 8-10.

In post 8 a restart, in post 9 "set the PATH", in post 10 explained that the restart simply let the change (to the path that the installation itself did) take hold globally (she/he was probably using a cmd shell that had been open for a while).

So, as you can see, the answer was already given. Please do not resurrect old threads unless absolutely necessary (which it almost never is).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sorry, but you do realise that this thread was over two years dead, until you rejuvinated it, right?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API docs for PreparedStatement. There are a plethora of set.... methods. One for each data type in the DB. The descriptions of these methods will tell you what object is needed to use it, and what data type is handled by it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, no. I wasn't trying to be harsh before. Sorry, if you took it that way. You're right here, about the cause, anyway, but there are a few other things as well.

public void service (HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
       	  
        HttpSession session = req.getSession(true);
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//Loading Sun's JDBC ODBC Driver
            theConnection = DriverManager.getConnection("jdbc:odbc:Dew", "", ""); //Connect to emaildb Data source
            Statement theStatement=theConnection.createStatement();

            String Fn  = req.getParameter("p1");
            String Ln  = req.getParameter("p2");
            String Em  = req.getParameter("p3");
            String un  = req.getParameter("p4");

            String updateString = "UPDATE T1 SET Fname =?, Lname=? WHERE username =?";
            PreparedStatement pStmt = theConnection.prepareStatement(updateString);
            pStmt.setString(1, Fn);
            pStmt.setString(2, Ln);
            pStmt.setString(3, un);

            ResultSet theResult = pStmt.executeQuery();

            theResult.close();//Close the result set		
            theStatement.close();//Close statement
            theConnection.close(); //Close database Connection 

        }catch(Exception e){
            out.println(e.getMessage());//Print trapped error.
        }

    }

should be

public void service (HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
       	  
        HttpSession session = req.getSession(true);
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        PreparedStatement theStatement = null;
        Connection theConnection = null;

        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//Loading Sun's JDBC ODBC Driver
            theConnection = DriverManager.getConnection("jdbc:odbc:Dew", "", ""); //Connect to emaildb Data source

            String Fn  = req.getParameter("p1");
            String Ln  = req.getParameter("p2");
            String Em  = req.getParameter("p3");
            String un  = req.getParameter("p4");

            String updateString = "UPDATE T1 SET Fname =?, Lname=? WHERE username =?";
            pStmt = theConnection.prepareStatement(updateString);
            pStmt.setString(1, Fn);
            pStmt.setString(2, Ln);
            pStmt.setString(3, un);

            int num = pStmt.executeUpdate();
        } catch(Exception e) {
            out.println(e.getMessage());//Print trapped error.
        } finally {
            if (theStatement != null) try { theStatement.close(); } catch (Exception e) {} //Close statement
            if (theConnection != null) try { theConnection.close(); } catch (Exception …
Sulley's Boo commented: hehe @ few .. looks A LOT to me :D .. anyway, you rock :D +3
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Create a File object from the given name and then do getName() (which a quick look at the APIs would tell you).

The concept remains the same, however. And, as I already said, don't use the URLEncoder (what do you think this does?).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, of course it is. What do you think the URLEncoder does?

You don't need to (and shouldn't) provide a path in that content header, anyway. Rather you should provide the filename only.

And you do realise, that the client (i.e. the machine from which the browser is running from) is not accessing the original file from the server, but rather a "copy" that is sent to it and placed in cache, right?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What does it print out between "welcome" and "times"?

And post your code again, using code tags, as I can not tell what quote you are using around your expr statement (and it makes a difference).

masijade 1,351 Industrious Poster Team Colleague Featured Poster
mysql options <<EOF
use dbName;
whatever;
EOF
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your "fix" to allow here cobbled together Statement to work, is, technically correct (although there is no reason to do a separate + "'" for everyone of the single quotes), however, she should not be using a cobbled together statement in the first place. What happens if one of the variables used contains a single quote (')? The statement will be broken. For that exact reason, the statement is also left wide open to SQL injection atacks.

@OP, use a PreparedStatement and its set... Methods

String updateString = "UPDATE T1 SET Fname =?, Lname=? WHERE username =?";
preparedStatement pStmt = conn.prepareStatement(updateString);
pStmt.setString(1, Fn);
pStmt.setString(2, Ln);
pStmt.setString(3, un);
int Upd = theStatement.executeUpdate();

And, if you have this code as a scriptlet in a JSP, remove it. Place all actual "code" into one (or more) beans. Scriptlets are strongly discouraged in the current version of JSP.

Sulley's Boo commented: Thank you boss .. +3