<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Dengues Studio: Google Group:http://groups.google.com/group/dengues; QQ Group:24885404.
    代碼可以參考:org.dengues.designer.core.launch.JavaETLProcessor.
    直接進入正題吧!第一種方法:使用Runtime.exec()方式.其實調用不難,關鍵就是要組織好它的命令參數.組織參數要注意:
    現在看Dengues源代碼里面的例子:
     1 public String[] getCommandLine(String[] libpath) {
     2         String command = "java"//$NON-NLS-1$
     3         StringBuffer libPath = new StringBuffer();
     4         String separator = System.getProperty("path.separator");
     5         for (String string : libpath) {
     6             libPath.append(FileUtils.getOSPath(string) + separator);
     7         }
     8         // init project_path
     9         String projectPath;
    10         IFolder classesFolder = getJavaProject().getProject().getFolder(JavaProcessorUtil.JAVA_PROJ_CLASSES); //$NON-NLS-1$
    11         IPath projectFolderPath = classesFolder.getFullPath().removeFirstSegments(1);
    12         projectPath = Path.fromOSString(project.getLocation().toOSString()).append(projectFolderPath).toOSString();
    13 
    14         // init class name
    15         IPath classPath = getCompiledCodePath().removeFirstSegments(1);
    16         String className = classPath.toString().replace('/''.');
    17 
    18         return new String[] { new Path(command).toPortableString(), "-Xms256M""-Xmx1024M""-cp"//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    19                 libPath.toString() + new Path(projectPath).toPortableString(), className };
    20     }

    這個是一個執行Java的命令行參數配置, 這里第一個直接用的java,其實更好一點話,你可以配置為java.exe全路徑.第二個,三個參數配置JVM的內存配置."-cp" 后跟的是要用的Jar包和Class目錄,也就是說他是這個java運行的classpath.最后的參數就是classname.也就是你要執行的Class.這個如果在Dengues里面的Preference頁測試一個連接生成一個Command命令: Command line:  java -Xms256M -Xmx1024M -cp E:\TEMP\db driver\mysql-connector-java-5.1.0-bin.jar;E:/workspaces/runtime-dengues.product/.Java/classes dengues.testcomponents.shadow.shadow_process.這樣這個ETLProcess就運行起來了.

    第二種方法:就是利用Eclipse Debug插件里面的在Dengues里面的代碼:
     1 public static ILaunch launch(IJavaProject proj, String name, String mainClass, String args) throws CoreException {
     2         ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
     3         ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
     4         ILaunchConfiguration config = null;
     5         // if the configuration already exists, use it!
     6         ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
     7         for (int i = 0; i < configurations.length; i++) {
     8             if (configurations[i].getName().equals(name))
     9                 config = configurations[i];
    10         }
    11         // else create a new one
    12         if (config == null) {
    13             ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name);
    14             wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, proj.getProject().getName());
    15             // current directory should be the project root
    16             wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, proj.getProject().getLocation().toString());
    17             // use the suplied args
    18             wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainClass);
    19             wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
    20             wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, PROCESS_FACTORY_ID);
    21             // saves the new config
    22             config = wc.doSave();
    23         }
    24         return config.launch(ILaunchManager.RUN_MODE, null);
    25     }

    不過這種方式需要注意的幾個問題:第一運行的class需要在一個IJavaProject里面.一般可以通過JavaCore.create(IProject project).來構造.它的優點就是你可以在整個Project里面設置classpath,還可以引用其他Project的內容;在Dengues里面JavaETLProcessor.initJavaPrject():
     1 public void initJavaProject() {
     2         if (javaProject != null) {
     3             return;
     4         }
     5         try {
     6             initProject();
     7             javaProject = JavaCore.create(project);
     8             IClasspathEntry classpathEntry = JavaCore.newSourceEntry(new Path("/" + project.getName() + "/" //$NON-NLS-1$ //$NON-NLS-2$
     9                     + JavaProcessorUtil.JAVA_PROJ_SRC));
    10             IClasspathEntry jreClasspathEntry = JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER")); //$NON-NLS-1$
    11             List<IClasspathEntry> classpath = new ArrayList<IClasspathEntry>();
    12             classpath.add(classpathEntry);
    13             classpath.add(jreClasspathEntry);
    14 
    15             classpath.addAll(addDriverClasses());
    16             classpath.addAll(addVariable(javaProject, "DENGUES_LIB", Activator.PLUGIN_ID));
    17             // add the classpath variables
    18             for (EClasspathVariables var : EClasspathVariables.values()) {
    19                 IClasspathEntry hsqlClasspathEntry = JavaCore.newVariableEntry(new Path(var.toString()), nullnull); //$NON-NLS-1$
    20                 classpath.add(hsqlClasspathEntry);
    21             }
    22             IFolder sourceFolder = project.getFolder(new Path(JavaProcessorUtil.JAVA_PROJ_SRC));
    23             if (!sourceFolder.exists()) {
    24                 sourceFolder.create(falsetruenull);
    25             }
    26             IFolder runtimeFolder = project.getFolder(new Path(JavaProcessorUtil.JAVA_PROJ_CLASSES));
    27             if (!runtimeFolder.exists()) {
    28                 runtimeFolder.create(falsetruenull);
    29             }
    30             javaProject.setRawClasspath(classpath.toArray(new IClasspathEntry[0]), null);
    31             javaProject.setOutputLocation(new Path("/" + project.getName() + "/" + JavaProcessorUtil.JAVA_PROJ_CLASSES), null); //$NON-NLS-1$ //$NON-NLS-2$
    32             // javaProject.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "1.6"); //$NON-NLS-1$ //$NON-NLS-2$
    33         } catch (Exception e) {
    34             log.error("initJavaProject Exception: ", e); //$NON-NLS-1$
    35         }
    36     }

    這樣就不需要設置執行參數.并且還可以在Console視圖里面看到執行的結果.就是說你在Eclipse執行一個程序的效果.








    Dengues論壇(http://groups.google.com/group/dengues/),一個很好的Eclipse開發者樂園.

    Feedback

    # re: [Dengues]在Eclipse中執行一個命令行命令,如 執行一個bat文件,或java , jar 等. 兩種方式:一是用Runtime.exec(),二是用Eclipse的launch().  回復  更多評論   

    2007-11-27 15:21 by nopper
    如何與小組成員取得聯系?

    # re: [Dengues]在Eclipse中執行一個命令行命令,如 執行一個bat文件,或java , jar 等. 兩種方式:一是用Runtime.exec(),二是用Eclipse的launch().  回復  更多評論   

    2007-12-11 18:04 by zDevil(Dengues Studio)
    你可以加入QQ群啊! Google Group:http://groups.google.com/group/dengues; QQ Group:24885404.

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    Dengues Studio: Google Group:http://groups.google.com/group/dengues; QQ Group:24885404.
    主站蜘蛛池模板: 无码人妻一区二区三区免费n鬼沢| 男人j进女人p免费视频| 亚洲免费福利在线视频| 亚洲人成在线免费观看| 精品特级一级毛片免费观看| 精品免费视在线观看| 女性无套免费网站在线看| 国产亚洲精品美女久久久| 亚洲乱码日产精品BD在线观看| 美女裸体无遮挡免费视频网站| 一级黄色免费毛片| 好男人www免费高清视频在线| 亚洲中文字幕久久精品无码APP | 97无码免费人妻超级碰碰夜夜| 免费一看一级毛片人| 亚洲三级视频在线观看| a一级毛片免费高清在线| 性做久久久久久久免费看| 亚洲成色www久久网站夜月| 美女露隐私全部免费直播| AV大片在线无码永久免费| 亚洲Av永久无码精品三区在线 | 亚洲色大18成人网站WWW在线播放 亚洲色大成WWW亚洲女子 | 久久久久亚洲精品日久生情 | 亚洲综合激情五月丁香六月| 永久免费av无码网站yy| 中文字幕无码成人免费视频| 爱情岛论坛网亚洲品质自拍| 国内精品免费久久影院| 亚洲三级在线播放| 大学生一级特黄的免费大片视频| 亚洲成a人片在线不卡一二三区| 伊人久久亚洲综合影院| 国产精品免费大片| 中文字幕乱码亚洲精品一区| www.亚洲精品.com| 麻豆高清免费国产一区| 亚洲AⅤ男人的天堂在线观看| 免费成人在线观看| 久久国产乱子免费精品| 亚洲AV色无码乱码在线观看|