avatar
weird class definition# Java - 爪哇娇娃
c*t
1
in hell.java class, I define it
import ....;
public class hell
{
private float var1=1;

public hell()
{
...;
}
...
public static void main()
{
hell a = new hell();
....
}
}
when I compile it, no problem. but when run java hell.class
it tells me Exception in thread "main" java.lang.NoClassDefFoundError
Anything wrong?
avatar
T*B
2
java hell

【在 c**t 的大作中提到】
: in hell.java class, I define it
: import ....;
: public class hell
: {
: private float var1=1;
:
: public hell()
: {
: ...;
: }

avatar
c*t
3
same error

【在 T***B 的大作中提到】
: java hell
avatar
T*B
4
java -classpath . hell

【在 c**t 的大作中提到】
: same error
avatar
c*t
5
same error

【在 T***B 的大作中提到】
: java -classpath . hell
avatar
m*t
6
Do you have file hell.class under the current directory
when you try it?

【在 c**t 的大作中提到】
: same error
avatar
T*B
7
write a 'hello world' and try again.

【在 c**t 的大作中提到】
: same error
avatar
c*t
8
if not use -classpth ., hello world will havve the same error
so it seems classpath error.
but I used classpath when run hell, still the same error
sounds weird

write a 'hello world' and try again.

【在 T***B 的大作中提到】
: write a 'hello world' and try again.
avatar
T*B
9
do you use 'package' in your code?

【在 c**t 的大作中提到】
: if not use -classpth ., hello world will havve the same error
: so it seems classpath error.
: but I used classpath when run hell, still the same error
: sounds weird
:
: write a 'hello world' and try again.

avatar
c*t
10
I comment it. So no 'package'

【在 T***B 的大作中提到】
: do you use 'package' in your code?
avatar
T*B
11
still stuck? you may post a simplified version of your code here.

【在 c**t 的大作中提到】
: I comment it. So no 'package'
avatar
e*e
12
so funny

try

public static void main(String[] args) {
}

【在 T***B 的大作中提到】
: java hell
avatar
v*e
13
post your full stacktrace. Which class it can't find?

【在 c**t 的大作中提到】
: in hell.java class, I define it
: import ....;
: public class hell
: {
: private float var1=1;
:
: public hell()
: {
: ...;
: }

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。