我的jdk怎么了? Main.java 中有class没有找到.注意大小写的问题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 java.lang是一个特殊的类库,她会自动导入每个Java File.在此我提供给你一个简单的Hello World例程,看是否和你的一样.附://:HelloWorld.javaimport java.util.*;public class HelloWorld{ public static void main(String[] args) { String pzzStr1; String pzzStr2; String pzzStr3; pzzStr1 = args[0]; pzzStr2 = args[1]; pzzStr3 = args[2]; System.out.println("Hello world!"); System.out.println(pzzStr1 + " " + pzzStr2 + " " + pzzStr3); }}///:~ HelloWorld.java 如下:import java.io.*;public class HelloWorld{ public static void main(String args[]){ System.out.println("Hello World"); }}Main.java 如下:/*// START array// Implementation of String.getChars().public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) { System.arraycopy(value, offset + srcBegin, dst, dstBegin, srcEnd - srcBegin);}// END array*/import java.util.Date;import java.util.Properties;import java.util.Enumeration;import java.io.*;class Main {// START errpublic static void usage() { System.err.println("Usage: testprog <username> <age>"); System.exit(-1);}// END err// START in// reads a line from standard inputpublic static String getLine() { StringBuffer buf = new StringBuffer(80); int c; try { while ((c = System.in.read()) != -1) { char ch = (char) c; if (ch == '\n') break; buf.append(ch); } } catch (IOException e) { System.err.println(e); } return (buf.toString());}// END inpublic static void setIO() { try {// START setIOSystem.setIn(new java.io.FileInputStream("myinputfile"));System.setOut(new PrintStream(new java.io.FileOutputStream("myoutputfile")));System.setErr(new PrintStream(new java.io.FileOutputStream("myerrinputfile")));System.out.println("Hello there file"); // using new outSystem.err.println("Hello there err file"); // using new err// END setIO} catch (java.io.IOException e) { e.printStackTrace();}}public static void main(String[] args) {// START date// Create a Date object using today's dateDate today = new Date(System.currentTimeMillis());System.out.println("Today: " + today.toString());// END date{// START getpropsProperties props = System.getProperties(); // get list of properties// Print properties using Enumerationfor (Enumeration enum = props.propertyNames(); enum.hasMoreElements();) { String key = (String)enum.nextElement(); System.out.println(key + " = " + (String)(props.get(key)));}// END getpropssetIO();}{// START getprop// get user's home directoryString homeDir = System.getProperty("user.home");// If 'outDir' not found, use 'homeDir' as defaultString outDir = System.getProperty("testdir", homeDir);// END getpropSystem.out.println("homeDir: " + homeDir);System.out.println("outDir: " + outDir);}/*// START getsec// Implementation of Thread.checkAccess()public final void checkAccess() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkAccess(this); }}// END getsec*/{String s1 = getLine();System.out.println("in: " + s1);}{// START setpropsProperties props = System.getProperties();// Add 'outDir' propertyprops.put("outDir", "/tmp");// overwrites System properties with new propertiesSystem.setProperties(props);// END setpropsSystem.out.println("outDir: " + System.getProperty("outDir"));}usage();}} 我把你的HelloWorld存成HelloWorld.javajavac HelloWorld.java通过java HelloWorld还是该例外 建议你这样public class Main{}我的JDK1.1.7是可以执行你上面的Main的。编译,执行都没有问题。 我现在觉得可能jdk1.2.2装的有问题 十之八九是classpath的問題,你的文件是否在classpath中包括的路徑里? 谢谢你,success!!不是将$JavaHome\bin和$JavaHome\jre\lib\rt.jar加入classpath就行吗?为何*.class也需要,请详述 $JavaHome\bin和$JavaHome\jre\lib\rt.jar只是JDK提供的标准库,你要运行自己的程序,当然要自己的*.class包含到CLASSPATH中才可以。以后自己的class多了,可以用jar命令作成package(*.jar),然后把此*.jar文件放到你的CLASSPATH中。 我知道了,一定是你的classpath里没有当前目录!呵呵,加一个 “.\;" in your classpath. i agree with people above ,sorry i can't input chinese now java.util.list问题 求用jAVA 实现声卡信号的采集 java 如果判别一个设备为物理设备还是虚拟设备? 请教大家一个正则表达式问题 关于学习tij 求Oracle8i SQLJ编程指南 大家一般是怎么测试自己做的程序的?向高手取经! System.getProperty("user.dir")的疑问 mouseDown方法为何不能重写? 我最近想作一些網絡開發﹐各位高手能不能提供一些關於snmp的資源和開發心得啊? Java applet与Mfc程序如何通过socket通讯? About rmi access builder
Hello World例程,看是否和你的一样.
附:
//:HelloWorld.java
import java.util.*;
public class HelloWorld
{
public static void main(String[] args) {
String pzzStr1;
String pzzStr2;
String pzzStr3;
pzzStr1 = args[0];
pzzStr2 = args[1];
pzzStr3 = args[2];
System.out.println("Hello world!");
System.out.println(pzzStr1 + " " + pzzStr2 + " " + pzzStr3);
}
}///:~
import java.io.*;public class HelloWorld{
public static void main(String args[]){
System.out.println("Hello World");
}
}Main.java 如下:/*
// START array
// Implementation of String.getChars().
public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
System.arraycopy(value, offset + srcBegin, dst, dstBegin,
srcEnd - srcBegin);
}
// END array
*/import java.util.Date;
import java.util.Properties;
import java.util.Enumeration;
import java.io.*;class Main {
// START err
public static void usage() {
System.err.println("Usage: testprog <username> <age>");
System.exit(-1);
}
// END err// START in
// reads a line from standard input
public static String getLine() {
StringBuffer buf = new StringBuffer(80);
int c;
try {
while ((c = System.in.read()) != -1) {
char ch = (char) c;
if (ch == '\n')
break;
buf.append(ch);
}
} catch (IOException e) {
System.err.println(e);
}
return (buf.toString());
}
// END inpublic static void setIO() {
try {
// START setIO
System.setIn(new java.io.FileInputStream("myinputfile"));
System.setOut(new PrintStream(new java.io.FileOutputStream("myoutputfile")));
System.setErr(new PrintStream(new java.io.FileOutputStream("myerrinputfile")));System.out.println("Hello there file"); // using new out
System.err.println("Hello there err file"); // using new err
// END setIO} catch (java.io.IOException e) {
e.printStackTrace();
}
}public static void main(String[] args) {
// START date
// Create a Date object using today's date
Date today = new Date(System.currentTimeMillis());
System.out.println("Today: " + today.toString());
// END date
{
// START getprops
Properties props = System.getProperties(); // get list of properties
// Print properties using Enumeration
for (Enumeration enum = props.propertyNames(); enum.hasMoreElements();) {
String key = (String)enum.nextElement();
System.out.println(key + " = " + (String)(props.get(key)));
}
// END getprops
setIO();
}
{
// START getprop
// get user's home directory
String homeDir = System.getProperty("user.home");
// If 'outDir' not found, use 'homeDir' as default
String outDir = System.getProperty("testdir", homeDir);
// END getprop
System.out.println("homeDir: " + homeDir);
System.out.println("outDir: " + outDir);
}
/*
// START getsec
// Implementation of Thread.checkAccess()
public final void checkAccess() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkAccess(this);
}
}
// END getsec
*/
{
String s1 = getLine();
System.out.println("in: " + s1);
}
{
// START setprops
Properties props = System.getProperties();
// Add 'outDir' property
props.put("outDir", "/tmp");
// overwrites System properties with new properties
System.setProperties(props);
// END setprops
System.out.println("outDir: " + System.getProperty("outDir"));
}usage();
}
}
javac HelloWorld.java通过
java HelloWorld
还是该例外
public class Main{
}
我的JDK1.1.7是可以执行你上面的Main的。
编译,执行都没有问题。
不是将$JavaHome\bin和$JavaHome\jre\lib\rt.jar加入classpath就行吗?
为何*.class也需要,请详述
只是JDK提供的标准库,
你要运行自己的程序,当然要自己的*.class包含到CLASSPATH中才可以。
以后自己的class多了,可以用jar命令作成package(*.jar),然后把此*.jar文件放到你的CLASSPATH中。
呵呵,加一个 “.\;" in your classpath.