java選項卡源代碼 java 選項卡

怎樣通過java源代碼得到.exe文件,各位高手請指點一下,我是新手。

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

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站設(shè)計、成都網(wǎng)站制作、常山網(wǎng)絡(luò)推廣、小程序設(shè)計、常山網(wǎng)絡(luò)營銷、常山企業(yè)策劃、常山品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供常山建站搭建服務(wù),24小時服務(wù)熱線:028-86922220,官方網(wǎng)址:muchs.cn

上次說了怎樣來生成可執(zhí)行jar文件,這次趁熱打鐵將一下用JSmooth把jar文件轉(zhuǎn)成可執(zhí)行exe文件。

這個很容易,roger就大體說一說吧。

JSmooth是免費軟件,可從下面網(wǎng)址下載:

安裝十分簡單,按next到finish就行了。roger裝的是0.9.6版本的,操作很簡單,如下。

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

界面有點土,但比其以前的版本已經(jīng)不錯了。

2. 從第一個選擇卡開始--skeleton,如果是需要標(biāo)準(zhǔn)輸入輸出的程序就選擇console,如果是window界面

的就選擇windowed。這里roger選windowed。

3。windows executabe中寫上你要生成的exe文件的名字,current directory不用寫,因為這是

console wrap 是找非同一級

目錄下資源用的。最后選擇圖標(biāo)。jip,gif,PNG的圖都可以,一般生成32*32的圖標(biāo)。

4。java applecation中先在classpath中選擇jar或zip文件,注意要是上次roger說的那種可執(zhí)行的。

然后在main-class中選擇主類名,自己寫也行,但要寫全(包括package)。如果有參數(shù)就寫上數(shù)。

5。剩下的3個選項卡基本不用寫了,主要是設(shè)置程序要求的jvm最低和最高版本,出錯時的提示信息,

要求的最大,最小內(nèi)存,System.getProperty() 方法需要的參數(shù)屬性等。JSmooth有manul手冊

寫的很詳細(xì),翻翻就知道了。

6。最后按那個齒輪按鈕或project--create exe,就生成了exe文件。project --〉run exe一下看看效 果。

java 源代碼 基礎(chǔ)點的 謝謝

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,"(.* */*/)")){ //判斷*/結(jié)尾的純注釋行

start=false;

return 1;

}

if(regCheck(s1,"(.* */*/.*)")!strCheck(s1)){ //判斷不是*/結(jié)尾的非純注釋行

if(strCheck(s1)){

start=false;

return 2;

}

}

if(start==true) //狀態(tài)代碼,start即/*開始時start=true*/結(jié)束時為false

return 1;

return 3;//ssssllll

}//aeee

/**

*

* @param s

* @param re

* @return boolean

*/

public boolean regCheck(String s,String re){ //正則表達(dá)試判斷方法

return Pattern.matches(re,s);

}

public boolean strCheck(String s){ //中間有*/的字符判斷 此方法最關(guān)鍵

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){ //此方法為我前面寫的字符串出現(xiàn)次數(shù)統(tǒng)計方法,不懂的可以看我前面的文章

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+"\"沒有出現(xiàn)過");

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(); //實例化一個文本域

//設(shè)置兩個按鈕

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

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

boolean isGo = false;

//構(gòu)造函數(shù)

public GoodLucky(){

b1.setActionCommand("start");//在開始按鈕上設(shè)置一個動作監(jiān)聽 start

JPanel p = new JPanel(); //實例化一個可視化容器

//將兩個按鈕添加到可視化容器上面,用add方法

p.add(b1);

p.add(b2);

//在兩個按鈕上增加監(jiān)聽的屬性,自動調(diào)用下面的監(jiān)聽處理方法actionPerformed(ActionEvent e),如果要代碼有更好的可讀性,可用內(nèi)部類實現(xiàn)動作

//監(jiān)聽處理。

b1.addActionListener(this);

b2.addActionListener(this);

//將停止按鈕設(shè)置為不可編輯(即不可按的狀態(tài))

b2.setEnabled(false);

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

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

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //設(shè)置用戶在此窗體上發(fā)起 "close" 時默認(rèn)執(zhí)行的操作,參數(shù)EXIT_ON_CLOSE是使用 System exit 方法退出應(yīng)用程序。僅在應(yīng)用程序中使用

this.setSize(300,200); //設(shè)置面板大小,寬和高

this.setLocation(300,300); //設(shè)置面板剛開始的出現(xiàn)的位置

Cursor cu = new Cursor(Cursor.HAND_CURSOR); //用指定名稱創(chuàng)建一個新的定制光標(biāo)對象,參數(shù)表示手狀光標(biāo)類型

this.setCursor(cu); //為指定的光標(biāo)設(shè)置光標(biāo)圖像,即設(shè)置光標(biāo)圖像為上面所創(chuàng)建的手狀光標(biāo)類型

this.setVisible(true); //將面板可視化設(shè)置為true,即可視,如果為false,即程序運行時面板會隱藏

tf.setText("welcome you! "); //設(shè)置面板的標(biāo)題為歡迎

this.go(); //調(diào)用go方法

}

public void go(){

while(true){ //這里是死循環(huán),也就是說用戶不點擊停止按鈕的話他一直循環(huán)出現(xiàn)隨機(jī)數(shù),直到用戶點擊停止按鈕循環(huán)才能推出,具體流程在actionPerformed方法中控制。

if(isGo == true){ //上面所定義的isGo的初始值為false,所以程序第一次到此會跳過

String s = ""; //設(shè)置空字符串

for(int j = 1; j = 7;j++){ //產(chǎn)生7個隨機(jī)數(shù)

int i = (int)(Math.random() * 36) + 1;//每個隨機(jī)數(shù)產(chǎn)生方式,這里定義靈活,可以自由定義隨機(jī)數(shù)產(chǎn)生的方式

if(i 10){

s = s + " 0" + i; //如果產(chǎn)生的隨機(jī)數(shù)小于10的話做處理:這里就牽扯到一個重要的概念,簡單敘述一下:

/*

當(dāng)一個字符串與一個整型數(shù)項相加的意思是連接,上面的s = s + " 0" + i的意思是字符串s鏈接0再連接整型i值,而不會導(dǎo)致0和整型的i相加,

產(chǎn)生的效果為s0i,由于s為空字符串(上面定義過的),所以當(dāng)i小于零時,在個位數(shù)前面加上0,比如產(chǎn)生的隨機(jī)數(shù)i為7的話,顯示效果為 07.

*/

}else{

s = s + " " + i; //如果產(chǎn)生的隨機(jī)數(shù)比10打的話,那么加上空格顯示,即數(shù)字和數(shù)字之間有個空格

}

//以上循環(huán)循環(huán)七次,以保證能出現(xiàn)7個隨機(jī)數(shù)

}

tf.setText(s); //將產(chǎn)生的隨機(jī)數(shù)全部顯示在文本域上,用文本域?qū)ο髏f調(diào)用它的設(shè)置文本的方法setText(String)實現(xiàn)。

}

//以下為線程延遲

try{

Thread.sleep(10); //線程類同步方法sleep,睡眠方法,括號里的單位為ms。

}catch(java.lang.InterruptedException e){

e.printStackTrace(); //異常捕獲,不用多說。

}

}

}

//以下是上面設(shè)置的事件監(jiān)聽的具體處理辦法,即監(jiān)聽時間處理方法,自動調(diào)用

public void actionPerformed(ActionEvent e){ //傳入一個動作事件的參數(shù)e

String s = e.getActionCommand(); //設(shè)置字符串s來存儲獲得動作監(jiān)聽,上面的start

/*

以下這個條件語句塊的作用為:用戶點擊開始后(捕獲start,用方法getActionCommand()),將命令觸發(fā)設(shè)置為true,從而執(zhí)行上面的go方法中的循環(huán)體(因為循環(huán)體中要求isGo參數(shù)為true,而初始為false)。

執(zhí)行循環(huán)快產(chǎn)生隨機(jī)數(shù),并將開始按鈕不可編輯化,而用戶只可以使用停止按鈕去停止。如果用戶按下停止時,也就是沒有傳入?yún)?shù)“start”的時候,

執(zhí)行else語句塊中的語句,isGo設(shè)置為false,將不執(zhí)行上面go中的循環(huán)語句塊,從而停止產(chǎn)生隨機(jī)數(shù),并顯示,并且把開始按鈕設(shè)置為可用,而把

停止按鈕設(shè)置為不可用,等待用戶按下開始再去開始新一輪循環(huán)產(chǎn)生隨機(jī)數(shù)。

*/

if(s.equals("start")){ //如果捕獲到start,也就是用戶觸發(fā)了動作監(jiān)聽器,那么下面處理

isGo = true; //設(shè)置isGo為true

b1.setEnabled(false); //將開始按鈕設(shè)置為不可用

b2.setEnabled(true); //將停止按鈕設(shè)置為可用

}else{

isGo = false; //將isGo設(shè)置為false,isGo為循環(huán)標(biāo)志位

b2.setEnabled(false); //設(shè)置停止按鈕為不可用(注意看是b2,b2是停止按鈕)

b1.setEnabled(true); //設(shè)置開始按鈕為可用

}

}

public static void main(String[] args){

new GoodLucky(); //產(chǎn)生類的實例,執(zhí)行方法

}

}

Java eclipse中無法查看源代碼

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

2.此時"Installed JRES"右邊是列表窗格,列出了系統(tǒng)中的JRE 環(huán)境,選擇你的JRE,然后點邊上的“Edit...“, 會出現(xiàn)一個窗口(Edit JRE) ;

3.選中rt.jar文件的這一項:“C:\Java\jdk1.5.0_04\jre\lib\rt.jar” 點 左邊的“+”號展開它(JDK實際安裝路徑以你的為準(zhǔn));

4.展開后,可以看到“Source Attachment:(none)”,點這一項,點右邊的按鈕“Source Attachment...“,選擇你的JDK目錄下的 “src.zip”文件;

5.一路點“ok”結(jié)束。

如何用java做出左側(cè)是菜單欄,單擊,右側(cè)可進(jìn)行頁面切換的效果,求源代碼

1、網(wǎng)頁:

(1)、用frameset加iframe

(2)、直接寫好div+css,左側(cè)導(dǎo)入菜單的頁面(import/link),右側(cè)導(dǎo)入不同的頁面

2、PC端:

用東南西北中的那個布局 BorderLayout

怎么在電腦上運行Java源程序代碼

首先你要在你的電腦上安裝jdk。你可以在后面鏈接地址下載適合你自己的版本(),如果這個鏈接過期了,請在這個首先找一找。

在你的電腦上配置java環(huán)境變量,主要是配置path和classpath。你可以百度java環(huán)境變量配置,可以找到很多java環(huán)境變量配置方法。配置完畢,可以在cmd窗口下用java -version來查看是否配置成功。如果顯示出java版本相關(guān)的信息表示配置成功,可以進(jìn)行下一步了。

編譯你的源代碼,cmd窗口下把路徑改變(cd)到你源代碼文件所在的路徑,然后用javac 源文件名編譯,例如javac Hello.java(需要注意的是源文件名需要是你文件public類的類名,如果你的文件有public類的話)。當(dāng)然你也可以不改變(cd)到源文件所在的路徑,你的文件就需要加上絕對路徑就可以了。例如:javac e:\src\Hello.java.

運行你編譯好的文件,java Hello(需要注意運行的時候沒有后綴.java或者.class),同樣你可以不改變路徑用絕對路徑運行,例如:java e:\src\Hello.如果你的代碼中有窗口這樣的類似的圖形化界面,你就需要用javaw來運行。

另外,你可以使用eclipse,NetBeans這樣的集成開發(fā)環(huán)境(IDE)來寫代碼,這樣方便很多。

高分求兩個簡單的JAVA設(shè)計源代碼

上面 wuzhikun12同學(xué)寫的不錯,但我想還不能運行,并且還不太完善。我給個能運行的:(注意:文件名為:Test.java)

//要實現(xiàn)對象間的比較,就必須實現(xiàn)Comparable接口,它里面有個compareTo方法

//Comparable最好使用泛型,這樣,無論是速度還是代碼量都會減少

@SuppressWarnings("unchecked")

class Student implements ComparableStudent{

private String studentNo; //學(xué)號

private String studentName; //姓名

private double englishScore; //英語成績

private double computerScore; //計算機(jī)成績

private double mathScore; //數(shù)學(xué)成績

private double totalScore; //總成績

//空構(gòu)造函數(shù)

public Student() {}

//構(gòu)造函數(shù)

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;

}

//實現(xiàn)compareTO方法

@Override

public int compareTo(Student student) {

double studentTotal = student.getTotalScore();

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

}

//重寫toString方法

public String toString(){

return "學(xué)號:"+this.getStudentNo()+" 姓名:"+this.getStudentName()+" 英語成績:"+this.getEnglishScore()+" 數(shù)學(xué)成績:"+this.getMathScore()+" 計算機(jī)成績:"+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())) { //照現(xiàn)實來說,比較是不是同一個學(xué)生,應(yīng)該只是看他的學(xué)號是不是相同

return true;

} else {

return false;

}

}

/*以下為get和set方法,我個人認(rèn)為,totalScore的set的方法沒必要要,因為它是由其它成績計算出來的

在set方法中,沒設(shè)置一次值,調(diào)用一次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子類學(xué)習(xí)委員類的實現(xiàn)

class StudentXW extends Student {

//重寫父類Student的testScore()方法

@Override

public double testScore() {

return sum()/3+3;

}

public StudentXW() {}

//StudentXW的構(gòu)造函數(shù)

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

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

}

}

//Student子類班長類的實現(xiàn)

class StudentBZ extends Student {

//重寫父類Student的testScore()方法

@Override

public double testScore() {

return sum()/3+5;

}

public StudentBZ() {}

//StudentXW的構(gòu)造函數(shù)

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()+"學(xué)生的評測成績?yōu)椋?+ avgScore+"分");

}

}

}

運行結(jié)果為:

張三學(xué)生的評測成績?yōu)椋?9.66666666666667分

李四學(xué)生的評測成績?yōu)椋?0.5分

王五學(xué)生的評測成績?yōu)椋?8.0分

李六學(xué)生的評測成績?yōu)椋?8.5分

朱漆學(xué)生的評測成績?yōu)椋?0.03333333333333分

網(wǎng)站標(biāo)題:java選項卡源代碼 java 選項卡
當(dāng)前URL:http://muchs.cn/article24/dococce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器動態(tài)網(wǎng)站、網(wǎng)頁設(shè)計公司、網(wǎng)站導(dǎo)航、電子商務(wù)、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化