需要帮助为java程序配置visual studio

时间:2016-05-22 21:22:44

标签: java visual-studio-2015 mingw-w64

我正在尝试编译一个简单的java程序,我是visual studio的新手。根据我在这里遵循的程序是我需要的compile.bat:

del Output /S /Q
mkdir Output
javac *.java -d Output
cd Output
start java MyApplication

以下是我将javac配置为外部工具的方法:

Screen Capture

这是java代码:

import java.io.*;
class HelloWorld {
    public static void main(String args[]) throws IOException
    {
        System.out.println("Hello World!");
        Scanner reader = new Scanner(System.in);  // Reading from System.in
        System.out.println("Enter a number: ");
        int n = reader.nextInt(); // Scans the next token of the input as an int.
        System.in.read();
    }
}

这是输出:

C:\>mkdir Output 
A subdirectory or file Output already exists.

C:\>javac *.java -d Output 
javac: file not found: *.java
Usage: javac <options> <source files>
use -help for a list of possible options

C:\>cd Output 

C:\Output>start java MyApplication 

正如您所看到的,VS不是从项目目录开始而是从C :(-(为什么?我如何修复它?)

Here我遵循的程序是什么。

我不知道怎么样;但它实际上似乎至少部分起作用。这是我的MinGw项目的项目目录:

C:\Users\sansari\Downloads\x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb\mingw64\java>ls
HelloWorld.class  HelloWorld.h  HelloWorld.java  ctest.c  ctest.dll

C:\Users\sansari\Downloads\x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb\mingw64\java>java HelloWorld
Enter a number:
2
Hello from C!

在另一个窗口中,我查找了java进程并尝试附加到它。这一次(我之前尝试了很多次)似乎有效:

C:\Users\sansari\Downloads\x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb\mingw64\java>tasklist | findstr java
java.exe                     10660 Console                    1     19,384 K

C:\Users\sansari\Downloads\x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb\mingw64\java>gdb -p 10660
GNU gdb (rubenvb-4.8.0) 7.5.91.20130322-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
For bug reporting instructions, please see:
<mingw-w64-public@lists.sourceforge.net>.
Attaching to process 10660
[New Thread 10660.0x2930]
[New Thread 10660.0x273c]
[New Thread 10660.0x25b4]
[New Thread 10660.0x1624]
[New Thread 10660.0x16e4]
[New Thread 10660.0x2788]
[New Thread 10660.0x254c]
[New Thread 10660.0x2984]
[New Thread 10660.0x1c7c]
[New Thread 10660.0x154]
[New Thread 10660.0x119c]
[New Thread 10660.0x1668]
[New Thread 10660.0x23b0]
[New Thread 10660.0x13e8]
[New Thread 10660.0xfc8]
[New Thread 10660.0xe88]
[New Thread 10660.0x22dc]
Reading symbols from C:\ProgramData\Oracle\Java\javapath\java.exe...(no debugging symbols found)...done.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) n
Single stepping until exit from function ntdll!DbgBreakPoint,
which has no line number information.
0x00007ffb6e409031 in ntdll!DbgUiRemoteBreakin () from C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) n
Single stepping until exit from function ntdll!DbgUiRemoteBreakin,
which has no line number information.
[Inferior 1 (process 10660) exited normally]
(gdb) n2
Undefined command: "n2".  Try "help".
(gdb)

如果你看到任何奇怪的东西,请告诉我。我会尝试多次运行它,看看我是否可以跟踪发生的事情。我没有例子,当你第一次运行GDB时看到了这么多新线程。我发现了一件事。我知道我需要使用-g选项来创建调试符号。我以为我这样做了,但我没有删除以前的文件。我要尝试一下。有人可以验证这可能导致GDB现在提供的有关调试符号的消息吗?

0 个答案:

没有答案