gpt4 book ai didi

blackberry - 打包 Blackberry OAuth 应用程序抛出错误

转载 作者:行者123 更新时间:2023-12-03 06:54:42 25 4
gpt4 key购买 nike

我正在创建一个应用程序,它将在 Twitter 上发布链接。以下代码拒绝为我打包,并抛出以下错误:

Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specified

这是代码:

public class ShowAuthBrowser extends MainScreen implements OAuthDialogListener
{
private final String CONSUMER_KEY = "<Consumer>";
private final String CONSUMER_SECRET = "<Secret>";
private LabelField _labelStutus;
private OAuthDialogWrapper pageWrapper = null;
public StoreToken _tokenValue;
public BrowserField b = new BrowserField();
Manager _authManager;
Manager _pinManager;
ButtonField authButton;
TextField authPin;

public ShowAuthBrowser()
{
_authManager = new VerticalFieldManager(NO_VERTICAL_SCROLL |
NO_VERTICAL_SCROLLBAR);
_pinManager = new HorizontalFieldManager(NO_VERTICAL_SCROLL |
NO_VERTICAL_SCROLLBAR);
authButton = new ButtonField("OK");
authPin = new TextField(Field.EDITABLE);
_authManager.add(_labelStutus );
_authManager.add(b);

_pinManager.add(authButton);
_pinManager.add(authPin);


pageWrapper = new BrowserFieldOAuthDialogWrapper(b,CONSUMER_KEY,
CONSUMER_SECRET,null,this);
pageWrapper.setOAuthListener(this);

add(_pinManager);
add(_authManager);

authButton.setChangeListener( new FieldChangeListener( ) {
public void fieldChanged( Field field, int context ) {
if( field == authButton ) {
doAuth(authPin.getText());
}
}
} );

}

public void doAuth( String pin )
{
try
{
if ( pin == null )
{
pageWrapper.login();
}
else
{
this.deleteAll();
add(b);
pageWrapper.login( pin );
}

}
catch ( Exception e )
{
final String message = "Error logging into Twitter: " +
e.getMessage();
Dialog.alert( message );
}
}

public void onAccessDenied(String response ) {

updateScreenLog( "Access denied! -> " + response );

}

public void onAuthorize(final Token token) {

final Token myToken = token;
_tokenValue = StoreToken.fetch();
_tokenValue.token = myToken.getToken();
_tokenValue.secret = myToken.getSecret();
_tokenValue.userId = myToken.getUserId();
_tokenValue.username = myToken.getUsername();
_tokenValue.save();

UiApplication.getUiApplication().invokeLater( new Runnable() {

public void run() {
deleteAll();
Credential c = new Credential(CONSUMER_KEY,
CONSUMER_SECRET,
myToken);
PostTweet tw = new PostTweet();
String message="Testing BB App";
boolean done=false;
done=tw.doTweet(message, c);
if(done == true)
{
Dialog.alert( "Tweet succusfully..." );
close();
}
}
});

}

public void onFail(String arg0, String arg1) {
updateScreenLog("Error authenticating user! -> " + arg0 + ", " + arg1);
}

private void updateScreenLog( final String message )
{
UiApplication.getUiApplication().invokeLater( new Runnable() {

public void run() {
_labelStutus.setText( message );
}
});
}
}

奇怪的是,如果我删除以下几行,它就可以正常打包:

authButton.setChangeListener( new FieldChangeListener( ) {
public void fieldChanged( Field field, int context ) {
if( field == authButton ) {
doAuth(authPin.getText());
}
}
} );

任何帮助将不胜感激,因为我确实需要将现场监听器附加到此屏幕。

使用像 authButton.setChangeListener(null) 这样的代码,它确实可以成功打包,但是我确实需要使用 FieldChangeListener 的代码来执行某些操作。

最佳答案

确保您的 java bin 路径已在环境变量中设置。

http://docs.oracle.com/javase/tutorial/essential/environment/paths.html

并查看以下网站中的最后 3 篇帖子:

http://supportforums.blackberry.com/t5/Java-Development/I-O-Error-Cannot-run-program-quot-jar-quot-CreateProcess-error-2/td-p/522638

还要确保计算机上安装了 Java® 软件开发工具包 (Java SDK/JDK),并且使用了正确版本的 Java SDK。

http://supportforums.blackberry.com/t5/Java-Development/I-O-Error-CreateProcess/ta-p/445949

正如下面 Scott Boettger 评论中提到的,这篇文章也可能会有所帮助: http://supportforums.blackberry.com/t5/Java-Development/why-cause-more-then-100-compiled-classes-packaging-I-O-error/m-p/520282

关于blackberry - 打包 Blackberry OAuth 应用程序抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10553003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com