• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Cannot compile on win2k and win98 platforms

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a program:
public class averfruit
{
public static void main(String[] args)
{
int orange=50;
int apple=20;
int average=0;
average = (orange + apple) / 2;
System.out.println("Average no. of fruit is : " + average);
}
}
I tried the full path to compile it with jdk1.3 and j2sdk1.4.
Both incurred the same errors:
averfruit.java:11: illegal character: \0
int apple = 20;
100 errors
I also tried to run it on win2k and win98 platforms, same errors.
However, I can compile this program by JBuilder5.
So, what's wrong with my code, the jdk or my OS?
Thanks
Andrew

 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It compiles fine for me using Win2K and jdk 1.3. I see nothing wrong with the code as posted here and come up with the correct result of

Average no. of fruit is : 35

Maybe something in your text editor is adding a hidden character?
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used notepad to write the code and compile it under MS-Dos env't by the Sun jdk1.3 and jdk1.4-beta3.
How can I fix it?
Thanks
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it can be compiled now.
Could you tell me how do you set the env't variables regarding the (1) path and (2) class path to the jdk1.4.../bin/ and jdk1.4.../lib/?
Regards
Andrew
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
win98
edit autoexec.bat
PATH=%PATH%;C:\jdk1.4...\bin\;C:\jdk1.4...\lib\
CLASSPATH=%CLASSPATH%;C:\Java(where you keep your source files)
You may find this page helpful.
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. How about win2k prof?
How should I set the environment variables?
I knew how to access it
right click the my computer icon and choose properties and then advance.
So, I mean the path which what should I set.
Regards
Andrew
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andrew,
The PATH environment variable has to include your JDK path. With 1.3 you don't really need to set a CLASSPATH
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
Co-author Mike Meyers' Java 2 Certification Passport
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. The env't variable was set properly now. I can use helios textpad to compile and run the code also.
Regards
Andrew
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic