|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

06-30-2008, 08:30 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
|
JDK 1.6 and Eclipse 6.0.1
Hi All
I have a problem to use JDK 1.6 and Eclipse 6.0.1. I got error like this
"Could not fiend main class.Progrram will exit"
How can i solve this..
|
|

06-30-2008, 09:45 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
Hello Mir,
I think ur environment variable's path for jdk is not set correctly, Check that.
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 10:19 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
Hello Mir,
I think ur environment variable's path for jdk is not set correctly, Check that.
Thxs for reply
Can tou tell how can i set correct set enviroment.Becouse i am setting through my computer ->Advance setting....
|
|

06-30-2008, 11:14 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
Yes there itself..
JAVA_HOME should be set to something like C:\Program Files\Java\jdk1.6.0_01
To check go to command prompt and type "java" u should get some response and even for javac. This would mean that ur java doesnt have any problem then we can chk out with eclipse for error.
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 12:06 PM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
Yes there itself..
JAVA_HOME should be set to something like C:\Program Files\Java\jdk1.6.0_01
To check go to command prompt and type "java" u should get some response and even for javac. This would mean that ur java doesnt have any problem then we can chk out with eclipse for error.
I did like same way and i check command promt.It is responding..
But eclipse error is same..
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
|
|

06-30-2008, 12:57 PM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
Oh ok got it...
I think the code u are trying to run is created in a different version of jdk which is not supported by jdk 6
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 01:48 PM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 01:49 PM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
Oh ok got it...
I think the code u are trying to run is created in a different version of jdk which is not supported by jdk 6
No Niveditha..
I try to run which is develop on jdk 6. Can you give me small code of jdk 6.
|
|

06-30-2008, 02:19 PM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
Hi,
Even i have jdk1.6 installed and the following code is running perfectly in my comp.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ProgressSample2 {
public static void main(String args[]) {
final JProgressBar aJProgressBar = new JProgressBar(0, 100);
aJProgressBar.setIndeterminate(true);
JButton aJButton = new JButton("Toggle");
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
boolean indeterminate = aJProgressBar.isIndeterminate();
aJProgressBar.setIndeterminate(!indeterminate);
}
};
aJButton.addActionListener(actionListener);
JFrame theFrame = new JFrame("Indeterminate");
theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = theFrame.getContentPane();
contentPane.add(aJProgressBar, BorderLayout.NORTH);
contentPane.add(aJButton, BorderLayout.SOUTH);
theFrame.setSize(300, 100);
theFrame.show();
}
}
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 02:24 PM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
Hi,
Even i have jdk1.6 installed and the following code is running perfectly in my comp.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ProgressSample2 {
public static void main(String args[]) {
final JProgressBar aJProgressBar = new JProgressBar(0, 100);
aJProgressBar.setIndeterminate(true);
JButton aJButton = new JButton("Toggle");
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
boolean indeterminate = aJProgressBar.isIndeterminate();
aJProgressBar.setIndeterminate(!indeterminate);
}
};
aJButton.addActionListener(actionListener);
JFrame theFrame = new JFrame("Indeterminate");
theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = theFrame.getContentPane();
contentPane.add(aJProgressBar, BorderLayout.NORTH);
contentPane.add(aJButton, BorderLayout.SOUTH);
theFrame.setSize(300, 100);
theFrame.show();
}
}
Sorry to say but i have same problem after run your code..
|
|

06-30-2008, 02:33 PM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
If u dont mind can u give me ur code i ll try to run it on my PC?
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 02:37 PM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
else it may be problem with a java version too that u have installed. Delete everything u have connected to java and install it freshly just like in a new machine.
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

06-30-2008, 05:54 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: SW MO, USA
Posts: 1,498
|
|
Bad version number in .class file
That could mean that the class file is from an younger version of Java, say 1.6 and the java program you are using is older and doesn't recognize the version number in the class file and gives that error message.
What version of java are you using to execute the class files?
Enter java -version to see what version. Here's what I see:
C:\Documents and Settings\Owner>java -version
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
|
|

07-01-2008, 07:17 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
else it may be problem with a java version too that u have installed. Delete everything u have connected to java and install it freshly just like in a new machine.
what you mean to delete jkd and jre or something more..
|
|

07-01-2008, 07:46 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
else it may be problem with a java version too that u have installed. Delete everything u have connected to java and install it freshly just like in a new machine.
See why i am trying do that becouse i want to add background picture on dailog box. Can you give me some code of set background picture(.gif) and set some label.. which is run on 1.5.
Plz help me
|
|

07-01-2008, 08:38 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
what you mean to delete jkd and jre or something more..
Yes i meant the same....
Can you give me some code of set background picture(.gif) and set some label.. which is run on 1.5.
i think this is the reason why u r getting error with jdk 1.6. Because the code was written in jdk1.5 and u r trying to run in jdk1.6,there may be some deprecated methods in the code that is not supported by jdk1.6 but were supported in jdk1.5
And code give me some time.
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

07-01-2008, 08:58 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
Yes i meant the same....
i think this is the reason why u r getting error with jdk 1.6. Because the code was written in jdk1.5 and u r trying to run in jdk1.6,there may be some deprecated methods in the code that is not supported by jdk1.6 but were supported in jdk1.5
And code give me some time.
Here is code which is written in 1.6
import java.awt.event.*;
import javax.swing.*;
public class Image extends JFrame {
private JPanel jPanel1;
private JButton jButton1;
private JLabel jLabel1;
public Image() {
jPanel1 = new JPanel();
jButton1 = new JButton("OK");
jLabel1 = new JLabel("your label goes here");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent evt) {
formWindowOpened(evt);
}
});
GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(139, 139, 139)
.addComponent(jButton1))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(126, 126, 126)
.addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(151, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(63, 63, 63)
.addComponent(jLabel1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 70, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(130, 130, 130))
);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}
private void formWindowOpened(WindowEvent evt) {
ImageIcon imageBack = new ImageIcon("images/master03_background.gif");
JLabel background = new JLabel(imageBack);
background.setBounds(0, 0, imageBack.getIconWidth(), imageBack.getIconHeight());
getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
jPanel1.setOpaque(false);
setContentPane(jPanel1);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Demo().setVisible(true);
}
});
}
}
Plz help me..
|
|

07-01-2008, 09:33 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
You can add the background image to a Jpanel and then add that panel into JDialog.
You will get lots of examples for adding background image to a Jpanel in google.Try once.
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

07-01-2008, 09:39 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Niveditha
You can add the background image to a Jpanel and then add that panel into JDialog.
You will get lots of examples for adding background image to a Jpanel in google.Try once.
I found some example but i am not abel to do that with dialog.you want to see my code of that..
help me
|
|

07-01-2008, 09:52 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
Hi,
Check this code its working fine...
import java.awt.* ;
import java.awt.Image;
import javax.swing.* ;
public class JFrameBg extends JFrame {
public JFrameBg() {
super() ;
setTitle( "Background Image on JFrame or JDialog or JApplet" ) ;
setDefaultCloseOperation( EXIT_ON_CLOSE ) ;
setContentPane( new MyPanel() ) ;
getContentPane().add( new JLabel( "It is a Label" , new ImageIcon( "D:/Personal/Shilu/teddy,bmp" ) , JLabel.CENTER ) ) ;
setSize( 400 , 300 ) ;
setVisible( true ) ;
}
public class MyPanel extends JPanel {
private Image img ;
public MyPanel() {
setLayout( new BorderLayout() ) ;
img = new ImageIcon( "D:/Personal/Shilu/rose.jpg" ).getImage() ;
if( img == null ) {
System.out.println( "Image is null" );
System.exit( 1 ) ;
}
if( img.getHeight(this) <= 0 || img.getWidth( this ) <= 0 ) {
System.out.println( "Image width or height must be +ve" );
System.exit( 2 ) ;
}
}
public void drawBackground( Graphics g ) {
int w = getWidth() ;
int h = getHeight() ;
int iw = img.getWidth( this ) ;
int ih = img.getHeight( this ) ;
for( int i = 0 ; i < w ; i+=iw ) {
for( int j = 0 ; j < h ; j+= ih ) {
g.drawImage( img , i , j , this ) ;
}
}
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
drawBackground( g ) ;
}
}
public static void main(String[] args) {
new JFrameBg() ;
}
}
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off | | | |