18 / 83
Jul 2004

You mean use the classes from JDK 1.4 with the VM of 1.3? Why would you want to do that?
In any case, it seems it wouldn't work (here with 1.4 and 1.5beta):

java -Xbootclasspath:/usr/local/opt/jdk1.5.0/jre/lib/rt.jar
Error occurred during initialization of VM
java.lang.NoSuchMethodError: java.lang.Thread.start()V

"Bytecode" language is added (simply send a .jar) smile We'll also add Nice, probably today..

Great, thanks a lot!

How are jars handled at the moment? Started with Main, the main-class in the manifest, both?

At present - with Main. We will add the manifest option when configuring Nice.

Is it possible to disable the inclusion of standard (library) classes in the jar file generated by the Nice compiler?

Not directly. Is that a problem?

I know the jar will be above the default limit, but that should not matter when submitting Nice source, right? Also, it's possible to use a tool to cut down on dead code. I tried proguard, and a simple Nice program gives a 17K jar file.

OK, jar files with/without manifests are now supported. Nice compiled to Bytecode works for TEST in 0.99s. The Nice compiler will be made available tomorrow.

Cool! I just solved TEST in 0.89s. Must have found a more clever algorithm wink

Did you also use a tool to cut down the size, or did you internally bypass the size limit to run a nice program as JAR?

I just changed the submission size limit for the problem TEST for a moment wink.

But thanks for mentioning proguard; I hadn't realised that there existed an open source java obfuscator. These can get quite handy sometimes, especially if privacy (not necessarily secrecy) of source code is required.

1 month later

I tried to use the JAVA class: com.braju.beta.format.Format and I am getting a compilation error. I read in a post that was added manually into the classpath...is it true? I was trying to see the diference between this and the standard InputStream reader for the palindrome problem.

regards

Raul

I am afraid the post you are referring to was a little out of date. Indeed, until about a month ago we were using Blackdown JAVA 1.3, and the com.braju.beta.format.Format was available (it worked about twice as slowly as normal IO).

This class was not included in the new Java installation (Sun JAVA 1.5 beta2) for the simple reason, that the newly added standard classes java.util.Scanner and Formatter (as well as the printf method for some other classes) seemed to make it redundant.

Please note that since Sun's JDK 1.5 beta2 differs significantly from 1.5 beta1, and is much closer to the current ReleaseCandidate, you should only use the official documentation of these classes, and not other sources found in the Internet (since they are mostly out of date).

The following is an example of code that will work with the online judge:

import java.util.Scanner;
class Main
{
   public static void main (String [] args)
   {
      /*
         // equivalent C code fragment
         int i;
         float f;
         char s [50];
         printf ("Enter three values -- integer float string: ");
         scanf ("%d %f %s", &i, &f, s);
         printf ("%d %f %s\n", i, f, s);
      */
      System.out.printf ("Enter three values -- " +
                        "integer float string: ");
      Scanner sc = new Scanner (System.in);
      int i = sc.nextInt ();
      float f = sc.nextFloat ();
      String s = sc.nextLine ();
      System.out.printf ("%d %f %s\n", i, f, s);
   }
}

But if you find that these classes do not meet your requirements, please let us know and we will add com.braju.beta.format to the classpath; this is no problem whatsoever.

Glup...well, not a nice increase in performance.

Seems pretty nice, thanks a lot.

Raul

1 year later

SPOJ is not accepting my code? cry

Both solutions mentioned above also give wrong answer! open_mouth

Why does SPOJ says that this code gives wrong answer? Any one who solved this in SPOJ please help.

they say, it will be 1 or 2 digits only. they won't test 421 on the code. so chill smile

1 year later

Hello,
does anybody know why my code is not accepted? I get "runtime error (NZEC)". Earlier when I additionally surrounded the code-line "x = eingabe()" with a try-catch block in order to catch a NumberFormatException from the parseInt()-method i even got "time limit exceeded"... On my machine it works correctly. Here is my code:

import java.util.Iterator;
import java.util.LinkedList;
public class Main
{
	public static void main(String[] args)
	{
		int x;
		LinkedList<Integer> l = new LinkedList<Integer>();
		while(true)
		{
			x = eingabe();
			if(x != 42)
			{
				l.add(new Integer(x));
			}
			else
			{
				break;
			}
		}
		for(Iterator<Integer> i = l.iterator();i.hasNext();)
		{
			System.out.println(i.next());
		}
      System.exit(0);
	}
	static int eingabe()
	{
		String s = "";
		try
		{
			s = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine();
		}
		catch (java.io.IOException e)
		{
		}
		return java.lang.Integer.parseInt(s);
	}	
}
16 days later

No, the solution is correct, since 420 is an invalid input stuck_out_tongue Read the problem statement.

4 years later

Why my following code get runtime error (NZEC)?
Help!!!
5293653 2011-06-25 11:17:31 Life, the Universe, and Everything runtime error (NZEC)edit run 0.28 177M JAVA

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;
public class Main
{
	private void solve() throws IOException
	{
		for (; ; )
		{
			int N = nextInt();
			if (N == 42)
				break;
			writer.println(N);
		}
	}
	public static void main(String arg[])
	{
		new Main().run();
	}
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	public void run()
	{
		try
		{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
			System.exit(1);
		}
	}
	int nextInt() throws IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException
	{
		return Double.parseDouble(nextToken());
	}
	String nextToken() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
		{
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}
2 months later

I'm getting a NZEC error in code..plz check and reply.
import java.util.*;
public class Main {

public static void main(String args[])
{
	Scanner in=new Scanner(System.in);
	System.out.println("enter the numbers: ");

	int n=0;int i=0;
	int arr[]=new int[10];

	while((n=in.nextInt())!=0)
	{arr[i]=n;	
		i++;

	}
	int j=0;
	while(arr[j]!=42)
	{System.out.println(arr[j]);
	j++;

}


}

}