java选项卡源代码 java 选项卡

怎样通过java源代码得到.exe文件,各位高手请指点一下,我是新手。

用JSmooth将jar文件生成exe文件- -

成都创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于网站设计、成都网站制作、常山网络推广、小程序设计、常山网络营销、常山企业策划、常山品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联公司为所有大学生创业者提供常山建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com

上次说了怎样来生成可执行jar文件,这次趁热打铁将一下用JSmooth把jar文件转成可执行exe文件。

这个很容易,roger就大体说一说吧。

JSmooth是免费软件,可从下面网址下载:

安装十分简单,按next到finish就行了。roger装的是0.9.6版本的,操作很简单,如下。

1。start -- programs -- JSmooth0.9.6 -- JSmoothGen

界面有点土,但比其以前的版本已经不错了。

2. 从第一个选择卡开始--skeleton,如果是需要标准输入输出的程序就选择console,如果是window界面

的就选择windowed。这里roger选windowed。

3。windows executabe中写上你要生成的exe文件的名字,current directory不用写,因为这是

console wrap 是找非同一级

目录下资源用的。最后选择图标。jip,gif,PNG的图都可以,一般生成32*32的图标。

4。java applecation中先在classpath中选择jar或zip文件,注意要是上次roger说的那种可执行的。

然后在main-class中选择主类名,自己写也行,但要写全(包括package)。如果有参数就写上数。

5。剩下的3个选项卡基本不用写了,主要是设置程序要求的jvm最低和最高版本,出错时的提示信息,

要求的最大,最小内存,System.getProperty() 方法需要的参数属性等。JSmooth有manul手册

写的很详细,翻翻就知道了。

6。最后按那个齿轮按钮或project--create exe,就生成了exe文件。project --〉run exe一下看看效 果。

java 源代码 基础点的 谢谢

package com.regex;

import java.io.*;

import java.net.URLDecoder;

import java.util.regex.*;

public class Regex {

private int REMARK=0;

private int LOGIC=0;

private int PHYSIC=0;

boolean start=false;

/**

* @param args

*/

public static void main(String[] args) { //测试方法

// TODO Auto-generated method stub

Regex re=new Regex();

re.regCount("Regex.java");

System.out.println("remark Line: "+re.REMARK);

System.out.println("logic Line: "+re.LOGIC);

System.out.println("physic Line: "+re.PHYSIC);

}/**

* @author BlueDance

* @param s

* @deprecated count

*/

public void regCount(String s){

String url=null;

try {

url=URLDecoder.decode(this.getClass().getResource(s).getPath(),"UTF-8");

} catch (Exception e) {

e.printStackTrace();

// TODO: handle exception

}

try {

BufferedReader br=new BufferedReader(new FileReader(new File(url)));

String s1=null;

while((s1=br.readLine())!=null){

PHYSIC++;

if(CheckChar(s1)==1){

REMARK++;

System.out.println("纯注释行:"+s1);

}

if(CheckChar(s1)==2){

LOGIC++;

REMARK++;

System.out.println("非纯注释行:"+s1);

}

if(CheckChar(s1)==3)

LOGIC++;

}

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}catch(IOException e){

e.printStackTrace();

}

}

/**

*

* @param s

* @return int

* @version check s

*/

public int CheckChar(String s){

String s1=null;

if(s!=null)

s1=s.trim();

//System.out.println(regCheck(s1,re));

if(regCheck(s1,"(//.*)")) //判断//开头的为纯注释行

return 1;

if(regCheck(s1,"(.*[;{})] *//.*)")) //判断不是//开头的非纯注释行

return 2;

if(regCheck(s1,"(//*.*)")){ //判断/*开头的纯注释行

start=true;

return 1;

}

if(regCheck(s1,"(.*[;{})]//*.*)")){ //判断不是/*开头的非纯注释行

start=true;

return 2;

}

if(regCheck(s1,"(.* */*/)")){ //判断*/结尾的纯注释行

start=false;

return 1;

}

if(regCheck(s1,"(.* */*/.*)")!strCheck(s1)){ //判断不是*/结尾的非纯注释行

if(strCheck(s1)){

start=false;

return 2;

}

}

if(start==true) //状态代码,start即/*开始时start=true*/结束时为false

return 1;

return 3;//ssssllll

}//aeee

/**

*

* @param s

* @param re

* @return boolean

*/

public boolean regCheck(String s,String re){ //正则表达试判断方法

return Pattern.matches(re,s);

}

public boolean strCheck(String s){ //中间有*/的字符判断 此方法最关键

if(s.indexOf("*/")0){

int count=0;

String y[]=s.split("/*/");

boolean boo[]=new boolean[y.length];

for (int i = 0; i y.length-1; i++) {

char c[]=y[i].toCharArray();

for (int j = 0; j c.length; j++) {

if(c[j]=='\\'c[j+1]=='"'){

count++;

}

}

if(count%2==0){

if(countNumber("\"",y[i])%2!=0){

boo[i]=true;

}else{

boo[i]=false;

}

}else{

if(countNumber("\"",y[i])%2==0){

boo[i]=true;

}else{

boo[i]=false;

}

}

}

for(int i=0;iboo.length;i++){

if(!boo[i])

return false;

}

return true;

}

return false;

}

public int countNumber(String s,String y){ //此方法为我前面写的字符串出现次数统计方法,不懂的可以看我前面的文章

int count=0;

String [] k=y.split(s);

if(y.lastIndexOf(s)==(y.length()-s.length()))

count=k.length;

else

count=k.length-1;

if(count==0)

System.out.println ("字符串\""+s+"\"在字符串\""+y+"\"没有出现过");

else

return count;

return -1;

}

}

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class GoodLucky extends JFrame implements ActionListener{

JTextField tf = new JTextField(); //实例化一个文本域

//设置两个按钮

JButton b1 = new JButton("开始");

JButton b2 = new JButton("停止");

boolean isGo = false;

//构造函数

public GoodLucky(){

b1.setActionCommand("start");//在开始按钮上设置一个动作监听 start

JPanel p = new JPanel(); //实例化一个可视化容器

//将两个按钮添加到可视化容器上面,用add方法

p.add(b1);

p.add(b2);

//在两个按钮上增加监听的属性,自动调用下面的监听处理方法actionPerformed(ActionEvent e),如果要代码有更好的可读性,可用内部类实现动作

//监听处理。

b1.addActionListener(this);

b2.addActionListener(this);

//将停止按钮设置为不可编辑(即不可按的状态)

b2.setEnabled(false);

this.getContentPane().add(tf,"North"); //将上面的文本域放在面板的北方,也就是上面(上北下南左西右东)

this.getContentPane().add(p,"South"); //将可视化容器pannel放在南边,也就是下面

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置用户在此窗体上发起 "close" 时默认执行的操作,参数EXIT_ON_CLOSE是使用 System exit 方法退出应用程序。仅在应用程序中使用

this.setSize(300,200); //设置面板大小,宽和高

this.setLocation(300,300); //设置面板刚开始的出现的位置

Cursor cu = new Cursor(Cursor.HAND_CURSOR); //用指定名称创建一个新的定制光标对象,参数表示手状光标类型

this.setCursor(cu); //为指定的光标设置光标图像,即设置光标图像为上面所创建的手状光标类型

this.setVisible(true); //将面板可视化设置为true,即可视,如果为false,即程序运行时面板会隐藏

tf.setText("welcome you! "); //设置面板的标题为欢迎

this.go(); //调用go方法

}

public void go(){

while(true){ //这里是死循环,也就是说用户不点击停止按钮的话他一直循环出现随机数,直到用户点击停止按钮循环才能推出,具体流程在actionPerformed方法中控制。

if(isGo == true){ //上面所定义的isGo的初始值为false,所以程序第一次到此会跳过

String s = ""; //设置空字符串

for(int j = 1; j = 7;j++){ //产生7个随机数

int i = (int)(Math.random() * 36) + 1;//每个随机数产生方式,这里定义灵活,可以自由定义随机数产生的方式

if(i 10){

s = s + " 0" + i; //如果产生的随机数小于10的话做处理:这里就牵扯到一个重要的概念,简单叙述一下:

/*

当一个字符串与一个整型数项相加的意思是连接,上面的s = s + " 0" + i的意思是字符串s链接0再连接整型i值,而不会导致0和整型的i相加,

产生的效果为s0i,由于s为空字符串(上面定义过的),所以当i小于零时,在个位数前面加上0,比如产生的随机数i为7的话,显示效果为 07.

*/

}else{

s = s + " " + i; //如果产生的随机数比10打的话,那么加上空格显示,即数字和数字之间有个空格

}

//以上循环循环七次,以保证能出现7个随机数

}

tf.setText(s); //将产生的随机数全部显示在文本域上,用文本域对象tf调用它的设置文本的方法setText(String)实现。

}

//以下为线程延迟

try{

Thread.sleep(10); //线程类同步方法sleep,睡眠方法,括号里的单位为ms。

}catch(java.lang.InterruptedException e){

e.printStackTrace(); //异常捕获,不用多说。

}

}

}

//以下是上面设置的事件监听的具体处理办法,即监听时间处理方法,自动调用

public void actionPerformed(ActionEvent e){ //传入一个动作事件的参数e

String s = e.getActionCommand(); //设置字符串s来存储获得动作监听,上面的start

/*

以下这个条件语句块的作用为:用户点击开始后(捕获start,用方法getActionCommand()),将命令触发设置为true,从而执行上面的go方法中的循环体(因为循环体中要求isGo参数为true,而初始为false)。

执行循环快产生随机数,并将开始按钮不可编辑化,而用户只可以使用停止按钮去停止。如果用户按下停止时,也就是没有传入参数“start”的时候,

执行else语句块中的语句,isGo设置为false,将不执行上面go中的循环语句块,从而停止产生随机数,并显示,并且把开始按钮设置为可用,而把

停止按钮设置为不可用,等待用户按下开始再去开始新一轮循环产生随机数。

*/

if(s.equals("start")){ //如果捕获到start,也就是用户触发了动作监听器,那么下面处理

isGo = true; //设置isGo为true

b1.setEnabled(false); //将开始按钮设置为不可用

b2.setEnabled(true); //将停止按钮设置为可用

}else{

isGo = false; //将isGo设置为false,isGo为循环标志位

b2.setEnabled(false); //设置停止按钮为不可用(注意看是b2,b2是停止按钮)

b1.setEnabled(true); //设置开始按钮为可用

}

}

public static void main(String[] args){

new GoodLucky(); //产生类的实例,执行方法

}

}

Java eclipse中无法查看源代码

1.点 “window“- “Preferences”- “Java” - “Installed JRES”;

2.此时"Installed JRES"右边是列表窗格,列出了系统中的JRE 环境,选择你的JRE,然后点边上的“Edit...“, 会出现一个窗口(Edit JRE) ;

3.选中rt.jar文件的这一项:“C:\Java\jdk1.5.0_04\jre\lib\rt.jar” 点 左边的“+”号展开它(JDK实际安装路径以你的为准);

4.展开后,可以看到“Source Attachment:(none)”,点这一项,点右边的按钮“Source Attachment...“,选择你的JDK目录下的 “src.zip”文件;

5.一路点“ok”结束。

如何用java做出左侧是菜单栏,单击,右侧可进行页面切换的效果,求源代码

1、网页:

(1)、用frameset加iframe

(2)、直接写好div+css,左侧导入菜单的页面(import/link),右侧导入不同的页面

2、PC端:

用东南西北中的那个布局 BorderLayout

怎么在电脑上运行Java源程序代码

首先你要在你的电脑上安装jdk。你可以在后面链接地址下载适合你自己的版本(),如果这个链接过期了,请在这个首先找一找。

在你的电脑上配置java环境变量,主要是配置path和classpath。你可以百度java环境变量配置,可以找到很多java环境变量配置方法。配置完毕,可以在cmd窗口下用java -version来查看是否配置成功。如果显示出java版本相关的信息表示配置成功,可以进行下一步了。

编译你的源代码,cmd窗口下把路径改变(cd)到你源代码文件所在的路径,然后用javac 源文件名编译,例如javac Hello.java(需要注意的是源文件名需要是你文件public类的类名,如果你的文件有public类的话)。当然你也可以不改变(cd)到源文件所在的路径,你的文件就需要加上绝对路径就可以了。例如:javac e:\src\Hello.java.

运行你编译好的文件,java Hello(需要注意运行的时候没有后缀.java或者.class),同样你可以不改变路径用绝对路径运行,例如:java e:\src\Hello.如果你的代码中有窗口这样的类似的图形化界面,你就需要用javaw来运行。

另外,你可以使用eclipse,NetBeans这样的集成开发环境(IDE)来写代码,这样方便很多。

高分求两个简单的JAVA设计源代码

上面 wuzhikun12同学写的不错,但我想还不能运行,并且还不太完善。我给个能运行的:(注意:文件名为:Test.java)

//要实现对象间的比较,就必须实现Comparable接口,它里面有个compareTo方法

//Comparable最好使用泛型,这样,无论是速度还是代码量都会减少

@SuppressWarnings("unchecked")

class Student implements ComparableStudent{

private String studentNo; //学号

private String studentName; //姓名

private double englishScore; //英语成绩

private double computerScore; //计算机成绩

private double mathScore; //数学成绩

private double totalScore; //总成绩

//空构造函数

public Student() {}

//构造函数

public Student(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {

this.studentNo = studentNo;

this.studentName = studentName;

this.englishScore = englishSocre;

this.computerScore = computerScore;

this.mathScore = mathScore;

}

//计算总成绩

public double sum() {

this.totalScore = englishScore+computerScore+mathScore;

return totalScore;

}

//计算评测成绩

public double testScore() {

return sum()/3;

}

//实现compareTO方法

@Override

public int compareTo(Student student) {

double studentTotal = student.getTotalScore();

return totalScore==studentTotal?0:(totalScorestudentTotal?1:-1);

}

//重写toString方法

public String toString(){

return "学号:"+this.getStudentNo()+" 姓名:"+this.getStudentName()+" 英语成绩:"+this.getEnglishScore()+" 数学成绩:"+this.getMathScore()+" 计算机成绩:"+this.getComputerScore()+" 总成绩:"+this.getTotalScore();

}

//重写equals方法

public boolean equals(Object obj) {

if(obj == null){

return false;

}

if(!(obj instanceof Student)){

return false;

}

Student student = (Student)obj;

if(this.studentNo.equals(student.getStudentName())) { //照现实来说,比较是不是同一个学生,应该只是看他的学号是不是相同

return true;

} else {

return false;

}

}

/*以下为get和set方法,我个人认为,totalScore的set的方法没必要要,因为它是由其它成绩计算出来的

在set方法中,没设置一次值,调用一次sum方法,即重新计算总成绩

*/

public String getStudentNo() {

return studentNo;

}

public void setStudentNo(String studentNo) {

this.studentNo = studentNo;

sum();

}

public String getStudentName() {

return studentName;

}

public void setStudentName(String studentName) {

this.studentName = studentName;

sum();

}

public double getEnglishScore() {

return englishScore;

}

public void setEnglishScore(double englishScore) {

this.englishScore = englishScore;

sum();

}

public double getComputerScore() {

return computerScore;

}

public void setComputerScore(double computerScore) {

this.computerScore = computerScore;

sum();

}

public double getMathScore() {

return mathScore;

}

public void setMathScore(double mathScore) {

this.mathScore = mathScore;

sum();

}

public double getTotalScore() {

return totalScore;

}

}

//Student子类学习委员类的实现

class StudentXW extends Student {

//重写父类Student的testScore()方法

@Override

public double testScore() {

return sum()/3+3;

}

public StudentXW() {}

//StudentXW的构造函数

public StudentXW(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {

super(studentNo,studentName,englishSocre,computerScore,mathScore);

}

}

//Student子类班长类的实现

class StudentBZ extends Student {

//重写父类Student的testScore()方法

@Override

public double testScore() {

return sum()/3+5;

}

public StudentBZ() {}

//StudentXW的构造函数

public StudentBZ(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {

super(studentNo,studentName,englishSocre,computerScore,mathScore);

}

}

//测试类

public class Test {

public static void main(String[] args) {

//生成若干个student类、StudentXW类、StudentBZ类

Student student1 = new Student("s001","张三",70.5,50,88.5);

Student student2 = new Student("s002","李四",88,65,88.5);

Student student3 = new Student("s003","王五",67,77,90);

StudentXW student4 = new StudentXW("s004","李六",99,88,99.5);

StudentBZ student5 = new StudentBZ("s005","朱漆",56,65.6,43.5);

Student[] students = {student1,student2,student3,student4,student5};

for(int i = 0 ; istudents.length; i++){

double avgScore = students[i].testScore();

System.out.println(students[i].getStudentName()+"学生的评测成绩为:"+ avgScore+"分");

}

}

}

运行结果为:

张三学生的评测成绩为:69.66666666666667分

李四学生的评测成绩为:80.5分

王五学生的评测成绩为:78.0分

李六学生的评测成绩为:98.5分

朱漆学生的评测成绩为:60.03333333333333分

网站标题:java选项卡源代码 java 选项卡
当前URL:https://www.cdcxhl.com/article24/dococce.html

成都网站建设公司_创新互联,为您提供云服务器动态网站网页设计公司网站导航电子商务网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

搜索引擎优化