在JB9中如何运行.java 文件

Peiyangjun_Pyj 2003-07-27 12:07:08
在JB9中如何运行.java 文件,我自己写了一个文件,包含有JFrame,我在命令行下用Javac和Java可以运行,没有任何问题。但是很不方便,我请问在JB下如何运行。请给出详细说明,谢谢
...全文
57 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Peiyangjun_Pyj 2003-07-29
  • 打赏
  • 举报
回复
to: loginworld(新寓) ,问题得到解决,谢谢
Peiyangjun_Pyj 2003-07-29
  • 打赏
  • 举报
回复
to: loginworld(新寓) ,问题得到解决,谢谢
loginworld 2003-07-28
  • 打赏
  • 举报
回复
在jb中新建工程,package,定义package,copy到相应目录下。run
Peiyangjun_Pyj 2003-07-28
  • 打赏
  • 举报
回复
以上两个文件可以的DOS下用 javac Sketcher.java和java Sketcher运行,没有任何问题
Peiyangjun_Pyj 2003-07-28
  • 打赏
  • 举报
回复
如下的两个文件:怎样在JB9中运行:
1
// Sketching application
import java.awt.*;
import java.awt.event.*;

public class Sketcher
{
public static void main(String[] args)
{
theApp = new Sketcher(); // Create the application object
theApp.init(); // ...and initialize it
}

// Initialization of the application
public void init()
{
window = new SketchFrame("Sketcher");
Toolkit theKit = window.getToolkit(); // Get the window toolkit
Dimension wndSize = theKit.getScreenSize(); // Get screen size

// Set the position to screen center & size to 2/3 screen size
window.setBounds(wndSize.width/6, wndSize.height/6, // Position
2*wndSize.width/3, 2*wndSize.height/3); // Size

window.addWindowListener(new WindowHandler()); // Add window listener
window.setVisible(true); // Display the window
}

// Handler class for window events
class WindowHandler extends WindowAdapter
{
// Handler for window closing event
public void windowClosing(WindowEvent e)
{
window.dispose(); // Release the window resources
System.exit(0); // End the application
}
}

private static SketchFrame window; // The application window
private static Sketcher theApp; // The application object
}
2
// Frame for the Sketcher application
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SketchFrame extends JFrame
{

// Constructor
public SketchFrame(String title)
{
setTitle(title); // Set the window title
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);


}


}
Peiyangjun_Pyj 2003-07-28
  • 打赏
  • 举报
回复
因为我只有.java 文件,而没有.jpx的工程文件,所以那个Run Project ----F9全是灰的,不能用
yhjvc 2003-07-27
  • 打赏
  • 举报
回复
找到主文件,然后点击运行。
unsalted 2003-07-27
  • 打赏
  • 举报
回复
右键run。
yayafans 2003-07-27
  • 打赏
  • 举报
回复
F9.

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧