小编sap*_*Pro的帖子

如何使用microsoft visual c ++编写代码来调用JNI

屏幕抓取

我该如何编写C代码microsoft visual c++ 2010 Express我无法做到.我正在编写一些C代码,但它编译时出错.

请建议一些方法来做到这一点?

我写了这段代码:

#include "jni.h"
#include "stdio.h"
#include "HelloWorld.h"

JNIEXPORT void JNICALL
Java_HelloWorld_print(JNIEnv *env, jobject obj) {
    printf("This is a JNI tester");
    return;
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

helloworld.cpp(1):致命错误C1083:无法打开包含文件:'jni.h'没有这样的文件或目录

c c++ java-native-interface visual-c++

6
推荐指数
1
解决办法
1万
查看次数

将窄字符串转换为宽字符串

我怎样才能将窄幅转换string为宽幅string

我试过这个方法:

string myName;
getline( cin , myName );
wstring printerName( L(myName) );  // error C3861: 'L': identifier not found
wchar_t* WprinterName = printerName.c_str(); // error C2440: 'initializing' : cannot convert from 'const wchar_t *' to 'wchar_t *'
Run Code Online (Sandbox Code Playgroud)

但我得到上面列出的错误.

为什么我会收到这些错误?我该如何解决它们?

有没有其他方法可以直接将narrow字符串转换为wide字符串?

c++ string unicode visual-c++

6
推荐指数
2
解决办法
2万
查看次数

在使用netbeans时向JTable添加数据

如何JTable在使用netbeans时添加数据.Netbeans在它的后代码中是这样的:

jTable1 = new javax.swing.JTable();
jTable1.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {null, null},
            {null, null},
            {null, null},
            {null, null}
        },
        new String [] {
            "Name", "Branch"
        }
    ) {
        boolean[] canEdit = new boolean [] {
            false, false
        };

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit [columnIndex];
        }
    }); // THIS IS THE SNIPPET GENERATED BY NETBEANS
    //( I have already created a table using the drag and drop fetaure of netbeans and this is the …
Run Code Online (Sandbox Code Playgroud)

java user-interface swing jtable

6
推荐指数
1
解决办法
5万
查看次数

a:悬停不起作用

HTML

 <table width="100%">
<tr>
    <td width="90%"></td>
    <td><a href="#" id="logout"><strong>Logout</strong></a></td>
 </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

CSS

@charset "utf-8";
/* CSS Document */

#logout {
color:#BBB;
}

a:hover {
color:#FFF;
}
Run Code Online (Sandbox Code Playgroud)

虽然注销的颜色似乎是css中给出的颜色,但是当我将鼠标放在链接上时(白色),颜色不会改变.是什么原因 ?

我必须告诉其他css文件,当鼠标放在它们上面并且它们工作正常时,往往会改变链接的颜色.

html css hover

6
推荐指数
1
解决办法
3万
查看次数

什么是弱全球参考?它与全球参考有何不同?

JNI中哪些弱全球参考?它与全局引用本地引用有何不同?

c java java-native-interface weak-references

6
推荐指数
1
解决办法
2662
查看次数

context.xml和server.xml之间的区别?

context.xmlTomcat和server.xmlTomcat有什么区别?如果我想添加一个标签,如:

    <Resource name="jdbc/MyDs" auth="Container" type="javax.sql.DataSource"
     driverClassName="org.apache.derby.jdbc.ClientDriver"
     url="jdbc:derby://localhost:1527/my_database;create=true"
     username="me" password="me" maxActive="20" maxIdle="10" maxWait="-1" />
Run Code Online (Sandbox Code Playgroud)

我应该在哪里添加它?

java tomcat java-ee

6
推荐指数
2
解决办法
1万
查看次数

javax.sound.sampled.LineUnavailableException :为什么我会收到此异常?

当执行以下方法时:

private void beep_player_1() {
    try {
        //clip_Player_2.close();
        clip_Player_1 = AudioSystem.getClip();
        ais = AudioSystem.getAudioInputStream(new File(Constants.Player1_Default_Tone)); // PATH FOR THE .WAV FILE
        clip_Player_1.open(ais);
        clip_Player_1.loop(0); // PLAY ONCE
    }catch(Exception exc) {
        System.out.println(exc);
     }
}
Run Code Online (Sandbox Code Playgroud)

LineUnavailableException被抛出。这可能是什么原因?

javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 24 bit, stereo, 6 bytes/frame, little-endian not supported.
Run Code Online (Sandbox Code Playgroud)

java javasound

6
推荐指数
1
解决办法
1万
查看次数

从jni c代码将jstring发送到接收字符串作为参数的java函数

如何将jstringJNI C代码中的a 发送给Java接收a String作为参数的函数?

我已经阅读过有关函数之类​​的信息,callVoidMethodA(....)但它们不接受诸如之类的任何东西jstring

c java string java-native-interface

5
推荐指数
1
解决办法
5687
查看次数

我使用restrict限定符时出错

当我编译以下程序时,我得到错误:

gcc tester.c -o tester

tester.c: In function ‘main’:
tester.c:7:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptr_X’
tester.c:7:17: error: ‘ptr_X’ undeclared (first use in this function)
tester.c:7:17: note: each undeclared identifier is reported only once for each function it appears in
tester.c:10:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptr_Y’
tester.c:10:17: error: ‘ptr_Y’ undeclared (first use in this function)
Run Code Online (Sandbox Code Playgroud)
#include <stdio.h>

int main() {
  int x = 10;
  int y = 20;

  int *restrict ptr_X; …
Run Code Online (Sandbox Code Playgroud)

c pointers restrict-qualifier

5
推荐指数
1
解决办法
779
查看次数

System.in.read实际返回了什么?

什么:

System.in.read()
Run Code Online (Sandbox Code Playgroud)

回来?该文件 说:

返回:数据的下一个字节,如果到达流的末尾,则返回-1.

但是,例如,如果我进入:10我回来了49.这是为什么 ?

java java-io

5
推荐指数
2
解决办法
1万
查看次数