java类不编译,是否可以编译一个java文件而不提供它的依赖?

There is a java file, which has some dependencies jars. But now, I don't have those jars, and I have to compile it to a .class file.

Is it possible to do this?

UPDATE

Thanks for your answers.

At first, I thought we can create some stubs for the missing dependencies, that's easy but boring. Since we can create the stubs without missing stubs to make the compiler happy, why can't we make a tool do it automatically? The tool doesn't need to create stubs, but reads the java file, collects informations, and then builds the .class files.

But if the "import" statements in the java file contain "*", that will be a problem:

import aaa.*

import bbb.*

public class Hello {

World world;

}

We don't know if the class "World" is under package "aaa" or "bbb". If we are not familiar with the missing dependencies, we even don't know how to create a stub for the class "World".

But if the "import" statements are clear, I think it's possible, but maybe no one will write such a tool

解决方案

You could go crazy and hand craft the required dependencies as stubs that do nothing except keep the compiler happy.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值