到目前为止,我知道我必须在哪里将外部JAR添加到传统Java文件夹中。
x64:const fs = require('fs-extra');
const request = require('request');
var probe = require('probe-image-size');
var progress = require('request-progress');
var filename = 'C:/Users/User/Desktop/myimage.jpg';
var writeSteam = fs.createWriteStream(filename)
var req = request(createRequestHeaders('www.linktomyimage.com/image.jpg'));
downloadImage(req, filename)
function createRequestHeaders(url) {
var cookie = `userid=${userid}; phash=${phash};`;
return {
'url': url,
'method': 'GET',
'gzip': true,
'headers': {
'Referer': `https://${website}/`,
'Cookie': cookie
}
};
}
function downloadImage(req, filename) {
return new Promise((resolve, reject) => {
var response = null;
var bytes;
var dirname = path.dirname(filename);
if (!fs.existsSync(dirname)) fs.ensureDirSync(dirname);
// NEW CODE
writeSteam.on('close', () => {
if (bytes !== writeSteam.bytesWritten) { // NEW CODE
// Here the write stream is closed, so we can compare the property bytesWritten with the bytes we expected to receive
console.log('The size is not equal! Image is corrupt!')
reject({ 'name': 'ImageCorrupt'})
} else if (response.statusCode === 200) {
var input = require('fs').createReadStream(filename);
probe(input).then(result => {
input.destroy();
if (result != null) {
resolve({bytes: bytes, width: result.width,
height: result.height,});
} else {
// The image size probe does not detect if the download was truncated
reject({ 'name': 'ImageMissingOrCorrupt'});
}
}).catch((error) => {
reject(error);
});
} else {
// This is never triggered when the download stops and the image is truncated
reject({ 'name': 'StatusCodeError', 'message': response.statusCode });
}
})
progress(req, { delay: 0 }).on('progress', function (state) {
updateDownloadSpeed(state.speed);
}).on('end', function () {
console.log('Ended request!!') // NEW CODE
}).on('response', function (resp) {
response = resp;
bytes = response.headers['content-length'];
}).on('error', function (error) {
// This does not detect when an image is truncated either
reject(error);
}).pipe(writeSteam);
});
}
但是对于OpenJDK,情况就不一样了。我无法到达必须放置外部广口瓶的地方。
C:\Program Files\Java\jdk1.8.0_201\jre\lib\my_jar.jar
不起作用。
创建C:\Program Files\AdoptOpenJDK\jdk-12.0.2.10-hotspot\lib
无效。
错误:
java.lang.ClassNotFoundException:org.mariadb.jdbc.Driver
答案 0 :(得分:0)
我很高兴C:\ Program Files \ AdoptOpenJDK \ jdk-12.0.2.10-hotspot \ lib不起作用。我认为您不应该在该位置放置外部广口瓶。您应该将它们放在其他位置,然后从那里引用。