简体   繁体   English

不只是java.lang *包时如何在Windows上运行compilr.com java .jar可执行文件

[英]How to run compilr.com java .jar executable on windows when its not just java.lang* package

I'm starting to code in Java in spare work time. 我开始在业余时间用Java编写代码。 Problem is everything is locked down and I'm kinda new to ask IT department to install ide or javac at least to me(im not in IT) so Im using Compilr.com which is quite awesome. 问题是一切都被锁定了,我是一个新问题,要求IT部门至少对我安装ide或javac(我不在IT中),所以Im使用Compilr.com真是太棒了。 Yet I tried to save and run the Hello world code already precoded there: 但是我尝试保存并运行已在此处预编码的Hello world代码:

public class ReadFile
{
    public static void main(String args[]) 
    {
        System.out.println("Hello World from Compilr!");
        System.out.println("Press any key to continue.");
        try {
            System.in.read();
        } catch (Throwable t) {}
    }
}

Then open windows cmd and run java -jar HelloWorld.jar Which Works. 然后打开Windows cmd并运行java -jar HelloWorld.jar。 Then I tried to build and run this code which throws the typical error that I havent properly setup classpath or some manifest made: 然后,我尝试构建并运行以下代码,该代码抛出典型的错误,即我没有正确设置类路径或某些清单:

import java.io.*;

public class ReadFile{
    public static void main(String[] args){
        try {

            FileReader input = new FileReader(args[0]);

            BufferedReader bufRead = new BufferedReader(input);

            String line;    
            int count = 0;  


            line = bufRead.readLine();
            count++;

            // Read through file one line at time. Print line # and line
            while (line != null){
                System.out.println(count+": "+line);
                line = bufRead.readLine();
                count++;
            }

            bufRead.close();

        }catch (ArrayIndexOutOfBoundsException e){

            System.out.println("Usage: java ReadFile filename\n");          

        }catch (IOException e){
            // If another exception is generated, print a stack trace
            e.printStackTrace();
        }

    }// end main
}

The thing it only generates a jar file so I dont have much of choice for compiling. 它只会生成一个jar文件,因此我没有太多选择可以编译。 How do I please make working code with all the available non-core java clasess? 我如何使用所有可用的非核心Java脚本编写工作代码? /At home I get error even on the helloworld program: Error:Could not find or load main class Program. /在家里,即使在helloworld程序上,我也会出错:错误:找不到或加载主类Program。

You should be able to install both JDK with Netbeans and Eclipse in a local directory without admin rights. 您应该能够在没有管理员权限的情况下在本地目录中安装带有Netbeans的JDK和Eclipse。 While it will be interesting to find out why compilr.com generated jar does not work for you for any serious work you will need a development environment. 找出为什么compilr.com生成的jar对于您进行的任何繁重的工作都不适合您是很有趣的,但您需要开发环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM