当前位置: 技术问答>java相关
我还需要哪些配置才能运行这个程序?
来源: 互联网 发布时间:2015-01-22
本文导语: 程序是这样的: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; public class ImageViewer extends JFrame implements ActionListener { public ImageViewer() { setTitle("ImageViewer"); setSize(300,400); ...
程序是这样的:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
public class ImageViewer extends JFrame implements ActionListener
{
public ImageViewer()
{
setTitle("ImageViewer");
setSize(300,400);
JMenuBar mbar = new JMenuBar();
JMenu m = new JMenu("File");
JMenuItem m1 = new JMenuItem("Open");
m1.addActionListener(this);
m.add(m1);
JMenuItem m2 = new JMenuItem("Exit");
m2.addActionListener(this);
m.add(m2);
mbar.add(m);
setJMenuBar(mbar);
Label = new JLabel();
Container contentPane = getContentPane();
contentPane.add(Label,"Center");
}
public void actionPerformed(ActionEvent evt)
{
String arg = evt.getActionCommand();
if(arg.equals("Open"))
{
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new javax.swing.filechooser.FileFilter()
{
public boolean accept(File f)
{
return f.getName().toLowerCase().endsWith(".gif");
}
public String getDescription()
{
return "GIF Image";
}
});
int r = chooser.showOpenDialog(this);
if(r == JFileChooser.APPROVE_OPTION)
{
String name = chooser.getSelectedFile().getName();
Label.setIcon(new ImageIcon(name));
}
}
//else if(arg.equals("Exit")) System.exit.(0);
}
public static void main(String[] args)
{
JFrame Frame = new ImageViewer();
Frame.show();
}
private JLabel Label;
}
运行是这样:
C:RESIN-1.3.B1docstudy>javac ImageViewer.java
C:RESIN-1.3.B1docstudy>java ImageViewer
Registry key 'SoftwareJavaSoftJava Runtime EnvironmentCurrentVersion'
has value '1.1', but '1.3' is required.
Error: could not find java.dll
Error: could not find Java 2 Runtime Environment.
我该怎么办?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
public class ImageViewer extends JFrame implements ActionListener
{
public ImageViewer()
{
setTitle("ImageViewer");
setSize(300,400);
JMenuBar mbar = new JMenuBar();
JMenu m = new JMenu("File");
JMenuItem m1 = new JMenuItem("Open");
m1.addActionListener(this);
m.add(m1);
JMenuItem m2 = new JMenuItem("Exit");
m2.addActionListener(this);
m.add(m2);
mbar.add(m);
setJMenuBar(mbar);
Label = new JLabel();
Container contentPane = getContentPane();
contentPane.add(Label,"Center");
}
public void actionPerformed(ActionEvent evt)
{
String arg = evt.getActionCommand();
if(arg.equals("Open"))
{
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new javax.swing.filechooser.FileFilter()
{
public boolean accept(File f)
{
return f.getName().toLowerCase().endsWith(".gif");
}
public String getDescription()
{
return "GIF Image";
}
});
int r = chooser.showOpenDialog(this);
if(r == JFileChooser.APPROVE_OPTION)
{
String name = chooser.getSelectedFile().getName();
Label.setIcon(new ImageIcon(name));
}
}
//else if(arg.equals("Exit")) System.exit.(0);
}
public static void main(String[] args)
{
JFrame Frame = new ImageViewer();
Frame.show();
}
private JLabel Label;
}
运行是这样:
C:RESIN-1.3.B1docstudy>javac ImageViewer.java
C:RESIN-1.3.B1docstudy>java ImageViewer
Registry key 'SoftwareJavaSoftJava Runtime EnvironmentCurrentVersion'
has value '1.1', but '1.3' is required.
Error: could not find java.dll
Error: could not find Java 2 Runtime Environment.
我该怎么办?
|
将'SoftwareJavaSoftJava Runtime EnvironmentCurrentVersion' 改为1.3即可
Java 2 Runtime Environment 1.3在jdk1.3中包含
如还不行,卸载java,删除'SoftwareJavaSoftJava Runtime Environment重新安装jdk1.3
Java 2 Runtime Environment 1.3在jdk1.3中包含
如还不行,卸载java,删除'SoftwareJavaSoftJava Runtime Environment重新安装jdk1.3
|
你用jdk甚麼版本
|
安装Java 2 Runtime Environment 1.3
|
u[