我设法在 netbeans 中编译并运行以下代码,但我想使用命令行语句编译和运行:
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.parseColor("#FFA800"));
Path path = new Path();
path.moveTo(0, 0);
path.lineTo(getWidth() / 2, 0);
path.lineTo(getWidth(), getHeight()/2);
path.lineTo(getWidth() / 2, getHeight());
path.lineTo( 0, getHeight());
path.lineTo( 0, 0);
canvas.drawPath(path, paint);
}
然后运行:
javac –cp "C:\Program Files\Java\jdk1.8.0_45\db\lib\odbc7.jar" OracleDBConnect.java
但是我收到了错误
java OracleDBConnect.java
我做错了什么?
no suitable driver found for jdbc:oracle:thin:@localhost:1521:XE
答案 0 :(得分:1)
运行类时需要设置类路径:
java –cp “C:\Program Files\Java\jdk1.8.0_45\db\lib\odbc7.jar” OracleDBConnect
编译时不需要包含odbc7.jar
,因为你没有直接引用它。
答案 1 :(得分:0)
您需要在类路径中添加依赖库并执行java
,例如:java -cp <libs ; separated> ClassName