Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 04-08-2008, 05:29 PM   #1 (permalink)
Excessive happiness
 
furious_gamer's Avatar
 
Join Date: Jun 2008
Location: Bangalore
Posts: 2,974
Default Java Queries Here..


I face a lot of issues while i m running java when i started to learn it... And i think the same issues will still alive.. If anyone find such kinda issue then please post it here instead of creating a new thread..

Yes this thread is dedicatedto Java(if u like J2EE toooo....)

So please drop ur queries here...
furious_gamer is online now   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 09-08-2008, 12:03 PM   #2 (permalink)
Excessive happiness
 
furious_gamer's Avatar
 
Join Date: Jun 2008
Location: Bangalore
Posts: 2,974
Default Re: Java Queries Here..

No Java Queries.....Thats so bad...
Instead of starting a new thread for ur java doubts plz try 2 post here.. This will help for newcomers to search their queries in one stop place...
__________________
My First Android phone : Samsung Galaxy SL i9003 - Rooted & Gingerbread XXKPQ
Updated : superteekz_V2 ROM for XXKPQ.

PS Request
furious_gamer is online now   Reply With Quote
Old 14-08-2008, 08:54 PM   #3 (permalink)
Indidiot
 
Plasma_Snake's Avatar
 
Join Date: Dec 2007
Location: Rock Island
Posts: 1,416
Default Re: Java Queries Here..

Check this code out:
Code:
import java.io.*;

public class FileOps {
public static void main(String args[])
{
    File file = new File(args[0]);
    try
    {
        BufferedReader in = new BufferedReader(new FileReader(file));
        String s;
        s = in.readLine();
        while(s!=null)
        {
            System.out.println("Read " + s);
            s = in.readLine();
        }
        in.close();
    }
    catch(FileNotFoundException e1)
    {
        System.err.println("File Not Found" + file);
    }
    catch(IOException e2)
    {
        e2.printStackTrace();
    }
}
}
Now I'm getting this error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at FileOps.main(FileOps.java:13)
Java Result: 1
"
What's the solution?
Plasma_Snake is offline   Reply With Quote
Old 14-08-2008, 09:57 PM   #4 (permalink)
Apprentice
 
Join Date: May 2006
Posts: 96
Default Re: Java Queries Here..

Just run the programme by giving the input file name at the command prompt. Syntax java classname inputfilename . Remember that input file should exist in same directory and should preferably be a text file.
__________________
learn how to earn money online : http://howearnmoney.50webs.com
amit_at_stg is offline   Reply With Quote
Old 14-08-2008, 10:40 PM   #5 (permalink)
CAFEBABE
 
chandru.in's Avatar
 
Join Date: Mar 2008
Location: Bangalore
Posts: 474
Default Re: Java Queries Here..

Quote:
Originally Posted by amit_at_stg View Post
Just run the programme by giving the input file name at the command prompt. Syntax java classname inputfilename . Remember that input file should exist in same directory and should preferably be a text file.
Just a small note. The file need not exist in the same directory from which the program is executed. In that case, the complete path (absolute path) of the files should be specified.
__________________
Chandru

http://tuxychandru.blogspot.com
chandru.in is offline   Reply With Quote
Old 14-08-2008, 10:54 PM   #6 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

+1 for the above 2 comments. I think you are not using the command prompt to run your java prog. Seems that you've configured some tool - like EditPlus or such. In that case, make sure that you chose the option that allows you to input parameters (just like command line parameters) to the program being run ("Prompt for Arguments" option in Editplus).

And yes, the file need not be in the same directory, but if the file or directory contains spaces, do enclose the entire path/name in double quotes.

- Bandu.
Bandu is offline   Reply With Quote
Old 14-08-2008, 11:06 PM   #7 (permalink)
Indidiot
 
Plasma_Snake's Avatar
 
Join Date: Dec 2007
Location: Rock Island
Posts: 1,416
Default Re: Java Queries Here..

I'm using Netbeans 6.1 and JDK 1.6
Plasma_Snake is offline   Reply With Quote
Old 14-08-2008, 11:18 PM   #8 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

I've never used Netbeans. Lookup for some help online for you to allow Netbeans to provide you a dialog for input parameters when you run FileOps.
Bandu is offline   Reply With Quote
Old 14-08-2008, 11:22 PM   #9 (permalink)
CAFEBABE
 
chandru.in's Avatar
 
Join Date: Mar 2008
Location: Bangalore
Posts: 474
Default Re: Java Queries Here..

Right click on your project in the Projects window and select properties.

Then select "Run" from the left and in the Arguments field type the absolute path to the file. Now whenever you run that will be passed to the program.
__________________
Chandru

http://tuxychandru.blogspot.com
chandru.in is offline   Reply With Quote
Old 18-08-2008, 02:58 PM   #10 (permalink)
I am the Legend.........
 
Join Date: Aug 2006
Location: sangli
Posts: 30
Default Re: Java Queries Here..

I am trying to use keylistener in java. Please expalain this error....

Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class sudoku1 extends Frame implements ActionListener,KeyListener {
    int i,j;
    int x,y;
    Button b;
    Graphics g;
    sudoku1(String s)
    {
            super(s);
            setTitle("Sudoku");
            setSize(1000,700);
            addKeyListener(this);           
            b=new Button("New Game");
            setLayout(new BorderLayout());
            b.addActionListener(this);
            add(b,BorderLayout.SOUTH);                     
            addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
            setVisible(true);
            g=getGraphics();        
    }
    /*public void control(KeyEvent e)
    {
            if(e.getKeyCode()==VK_ENTER)
                JOptionPane.showMessageDialog(null,"right");
    }*/
    public void keyPressed(KeyEvent e)
    {
        if(e.getKeyCode()==VK_RIGHT)
                JOptionPane.showMessageDialog(null,"right");
    }
    public void keyReleased(KeyEvent e){}
    public void keyTyped(KeyEvent e){}
    public void draw()
    {                
       g.setColor(Color.BLUE);
       x=500;
       y=350;
       i=j=0;
        while(i<10) //platform of the game is printed on screen.
	{
		g.drawLine(x-270+60*i,y-270,x-270+60*i,y+270);
		g.drawLine(x-270,y-270+60*i,x+270,y-270+60*i);
		if(i==3||i==6)
		{
			g.drawLine(x-270+60*i+2,y-270,x-270+60*i+2,y+270);
			g.drawLine(x-270,y-270+60*i+2,x+270,y-270+60*i+2);
		}
		i++;
	}
   
    }       
    public void actionPerformed(ActionEvent e)
    {
        if(e.getSource()==b)
            draw();
    }
    public static void main(String[] args) {
        // TODO code application logic here
        sudoku1 m=new sudoku1("Sudoku");
        
    }

}
error is:

can't find symbol
symbol : variable VK_RIGHT

if(e.getKeyCode()==VK_RIGHT
__________________
a sudoku web app designed using gwt and gae.- http://solvemysudoku.appspot.com
my blog- http://aniketawati.blogspot.com
aniket.awati is offline   Reply With Quote
Old 18-08-2008, 03:03 PM   #11 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

There's an error in the code. Use KeyEvent.VK_RIGHT instead of VK_RIGHT. Change your if condition as follows:

Code:
if(e.getKeyCode()==KeyEvent.VK_RIGHT)
Bandu is offline   Reply With Quote
Old 18-08-2008, 03:11 PM   #12 (permalink)
I am the Legend.........
 
Join Date: Aug 2006
Location: sangli
Posts: 30
Default Re: Java Queries Here..

thanks that solved it.
__________________
a sudoku web app designed using gwt and gae.- http://solvemysudoku.appspot.com
my blog- http://aniketawati.blogspot.com
aniket.awati is offline   Reply With Quote
Old 18-08-2008, 04:23 PM   #13 (permalink)
Indidiot
 
Plasma_Snake's Avatar
 
Join Date: Dec 2007
Location: Rock Island
Posts: 1,416
Default Re: Java Queries Here..

this not a programming query but a simple JAVA related query. My friends have been asked lot of times during Viva and Placement interview that, Why the symbol of Java is cup of Coffee? AFAIK and tell 'em cause Java is also a name for a type of coffee and is also synonymous to Coffee in some countries that's why its Java and earlier Javabeans(now Netbeans). If I'm wrong then please do correct me.
Plasma_Snake is offline   Reply With Quote
Old 18-08-2008, 04:52 PM   #14 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

Me too thinks the same.

I've heard of a couple of theories:
(1) James Gosling thought of it while having a cup of coffee.
(2) They had earlier thought of the name (and possibly the symbol) Oak, but that had some copyright issues. They then hired a consultant who interviewed the team and came up with a list of names (Silk, Java, etc.). Java was chosen as it sounds refreshing.
(3) And this, to me seems the most reasonable answer to your question:

"The letters spell out the names of the three key developers: James Gosling, Arthur Van Hoff and Andy Bechtolsheim."
Bandu is offline   Reply With Quote
Old 23-08-2008, 10:03 PM   #15 (permalink)
GaurishSharma.com
 
gary4gar's Avatar
 
Join Date: May 2005
Location: Jaipur
Posts: 4,116
Default Re: Java Queries Here..

any Good IDE for java?
gary4gar is offline   Reply With Quote
Old 23-08-2008, 10:04 PM   #16 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

Get IntelliJ IDEA if you / your company can affort it. Its the best one out there.
Eclipse is one of the freely available ones and is quite good too.

- Bandu.
Bandu is offline   Reply With Quote
Old 23-08-2008, 10:21 PM   #17 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: Java Queries Here..

Quote:
Originally Posted by gary4gar View Post
any Good IDE for java?
NetBeans - The only IDE you need !
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline   Reply With Quote
Old 23-08-2008, 10:25 PM   #18 (permalink)
18 Till I Die............
 
Join Date: Jul 2004
Location: India, Mumbai, Marine Lines
Posts: 5,792
Default Re: Java Queries Here..

geany
__________________
http://www.bash.org/?258908
mehulved is offline   Reply With Quote
Old 23-08-2008, 11:00 PM   #19 (permalink)
GaurishSharma.com
 
gary4gar's Avatar
 
Join Date: May 2005
Location: Jaipur
Posts: 4,116
Default Re: Java Queries Here..

Quote:
Originally Posted by mehulved View Post
geany
Oh yeah...i forgot that geany is not only for C/C++ but for java too, thanks for reminding me

Quote:
Originally Posted by Garbage View Post
NetBeans - The only IDE you need !
Its good for large scale projects, else i am better off with Eclipse or geany

Last edited by gary4gar; 23-08-2008 at 11:01 PM. Reason: Automerged Doublepost
gary4gar is offline   Reply With Quote
Old 26-08-2008, 08:18 PM   #20 (permalink)
Right Off the Assembly Line
 
Join Date: Jan 2007
Posts: 5
Default Re: Java Queries Here..

Well could you guys WAP in java to print the following pattern?? (Just give the base logic using the for loop)

*
**
***
****
***
**
*

the pattern is in the center with 1 star, next line two stars then next line 3 stars ..... 4 stars then decreasing to 1 star...

thanks

Last edited by aniruddhc; 26-08-2008 at 08:19 PM. Reason: Automerged Doublepost
aniruddhc is offline   Reply With Quote
Old 26-08-2008, 08:28 PM   #21 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

^^ I hope thats not a school assignment.

Anyways, the logic is pretty simple.
(1) Have an outer loop iterate thru 0 to 4. End it with System.out.println().
(2) Have an inner loop iterate through 0 till i and print a single *.

The above steps will give you the first part of the pattern. Reverse the logic to get the lower half.

- Bandu.
P.S. There are other ways to do this and there might be more simpler ways as well.
Code:
for(int i = 0; i < 4; i++, System.out.println())
            for(int j = 0; j <= i; j++)
                System.out.print("*");
Edit: The thread subscription email that I received has a different pattern. If it is the exact opposite of whats seen in the thread, then u'll have to slightly modify the loop structures:
Code:
for(int i = 0; i < 4; i++, System.out.println())
  {
   for(int j = 4; j > i; j--)
    System.out.print(" ");
   for(int k = 0; k <= i; k++)
    System.out.print("*");
  }

Last edited by Bandu; 26-08-2008 at 08:37 PM.
Bandu is offline   Reply With Quote
Old 27-08-2008, 10:56 AM   #22 (permalink)
Excessive happiness
 
furious_gamer's Avatar
 
Join Date: Jun 2008
Location: Bangalore
Posts: 2,974
Default Re: Java Queries Here..

Quote:
Originally Posted by Bandu View Post
^^ I hope thats not a school assignment.

Anyways, the logic is pretty simple.
(1) Have an outer loop iterate thru 0 to 4. End it with System.out.println().
(2) Have an inner loop iterate through 0 till i and print a single *.

The above steps will give you the first part of the pattern. Reverse the logic to get the lower half.

- Bandu.
P.S. There are other ways to do this and there might be more simpler ways as well.
Code:
for(int i = 0; i < 4; i++, System.out.println())
            for(int j = 0; j <= i; j++)
                System.out.print("*");
Edit: The thread subscription email that I received has a different pattern. If it is the exact opposite of whats seen in the thread, then u'll have to slightly modify the loop structures:
Code:
for(int i = 0; i < 4; i++, System.out.println())
  {
   for(int j = 4; j > i; j--)
    System.out.print(" ");
   for(int k = 0; k <= i; k++)
    System.out.print("*");
  }
He just ask the logic, but u provide him the code....
__________________
My First Android phone : Samsung Galaxy SL i9003 - Rooted & Gingerbread XXKPQ
Updated : superteekz_V2 ROM for XXKPQ.

PS Request
furious_gamer is online now   Reply With Quote
Old 27-08-2008, 01:55 PM   #23 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

Quote:
Originally Posted by rajkumar_pb View Post
He just ask the logic, but u provide him the code....
I kinda disappointed Aniruddh the last time with his Electronic showroom thing, and he's really at a very early stage of learning, so I thought it might help him better this way than exchaning multitude of PM's and emails for a trivial thing as this.

- Bandu.
Bandu is offline   Reply With Quote
Old 02-09-2008, 01:05 AM   #24 (permalink)
Right Off the Assembly Line
 
Join Date: Jan 2007
Posts: 5
Default Re: Java Queries Here..

Bandu I need to make the pattern in a diamond shape... The digit forum fsoftware doesnt allow me to post it in a diamond way

i think i need 6 loops, but i am not sure...

your logic unfortunately does not work...
aniruddhc is offline   Reply With Quote
Old 02-09-2008, 01:42 PM   #25 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Java Queries Here..

@Aniruddh, post your required output enclosed in [ CODE] [/ CODE].

Quote:
Originally Posted by aniruddhc View Post
your logic unfortunately does not work...

Last edited by Bandu; 02-09-2008 at 02:01 PM. Reason: Automerged Doublepost
Bandu is offline   Reply With Quote
Old 06-09-2008, 11:22 AM   #26 (permalink)
In The Zone
 
Join Date: Oct 2006
Location: Mumbai
Posts: 365
Default Re: Java Queries Here..

how to use java persistence api in core java?
__________________
Dhiraj Thakur
thakur.dheeraj(@)gmail.com
Desi-Tek.com is offline   Reply With Quote
Old 06-09-2008, 01:08 PM   #27 (permalink)
CAFEBABE
 
chandru.in's Avatar
 
Join Date: Mar 2008
Location: Bangalore
Posts: 474
Default Re: Java Queries Here..

^^ See here.

http://en.wikibooks.org/wiki/Java_Pe...andard_Edition
__________________
Chandru

http://tuxychandru.blogspot.com
chandru.in is offline   Reply With Quote
Old 06-09-2008, 04:10 PM   #28 (permalink)
In The Zone
 
Join Date: Oct 2006
Location: Mumbai
Posts: 365
Default Re: Java Queries Here..

Quote:
Originally Posted by chandru.in View Post
that example is for ejb which require application server but i want to use jpa in core java application.
__________________
Dhiraj Thakur
thakur.dheeraj(@)gmail.com
Desi-Tek.com is offline   Reply With Quote
Old 06-09-2008, 05:12 PM   #29 (permalink)
CAFEBABE
 
chandru.in's Avatar
 
Join Date: Mar 2008
Location: Bangalore
Posts: 474
Default Re: Java Queries Here..

See the section titled "Java Standard Edition".

It does work without Java EE server.
__________________
Chandru

http://tuxychandru.blogspot.com
chandru.in is offline   Reply With Quote
Old 06-09-2008, 11:12 PM   #30 (permalink)
In The Zone
 
Join Date: Oct 2006
Location: Mumbai
Posts: 365
Default Re: Java Queries Here..

but how to use it with core java? do u have any example?
__________________
Dhiraj Thakur
thakur.dheeraj(@)gmail.com
Desi-Tek.com is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java programming..how can I distribute java program....? Manojap Programming 5 16-05-2009 02:46 PM
What is more powerfule Core Java or Java ? avadhesh QnA (read only) 4 06-05-2008 04:55 PM
Post ur Java Queries Here Gigacore Programming 11 28-10-2007 01:05 PM
C,Java queries. ~Phenom~ Software Q&A 3 15-09-2006 12:07 AM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:08 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2