Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Tuners
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    2. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    3. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    6. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

bluej error


ramarar
 Share

Recommended Posts

I have been trying to run some string classes in java through bluej but keep encountering this error

 

Error: cannot find symbol class lang

 

during runtime. I have tried reinstalling java and bluej but it didn't work. Any solutions for this?

Link to comment
Share on other sites

Never heard of bluej.

 

 

(after a 1 minute briefing on bluej)Make sure you have a constructor and it is the same name as the class. It sounds like bluej gives you a base framework when you start a project. I'm willing to bet that it is something silly that you will want to kick yourself for not seeing once you get it working.

 

If you want to post your code here(use
 tags) we can help debug.

 

Maybe switch to eclipse as your java IDE.

You can help with graphics for an Xbox game.  Check out this thread here at GTAF for more info.

 

FREE!!! FREE!!! Free copy of my crappy little Xbox/Windows game NewZerk!!! <--Click to redeem free code!

MBMP1oP.png

Link to comment
Share on other sites

public class initials{    public initials(String x)    {int n=x.length();char []a=x.toCharArray();System.out.print(x.charAt(0)+".");for(int i=1;i<=n;i++){if(a[i]==' ')    {        System.out.println(a[i+1]+".");    }}}}

Well I ran this same code at school and it worked fine which makes me rule out any error in the code but I might be missing something too.

Bluej is described to us at school for our computer syllabus which is why I am preferring it to eclipse.

Link to comment
Share on other sites

It's fairly straight-forward code so I'm not sure what's causing the error. Maybe check your Java SDK installation.

 

But, I'd recommend using split, rather than parsing an array of characters. If you use x.split(" ") then it will return an array containing all the words in the string. It will be easier to work with, as well as having much better performance. Okay, that's not really an issue with such a simple function, but it makes sense to get used to always looking for the best performance, as long as it doesn't make the code unreadable.

Link to comment
Share on other sites

That code throws an IndexOutOfBoundsException everytime you run it:

 

This line:

for(int i=1;i<=n;i++)

should be like this:

for(int i=1;i<n;i++)

 

Youre using an array, the last index is n-1, not n.

Edited by reiniat
Link to comment
Share on other sites

I must have made an error in typing over there but other than this what can I do to solve the error. Could the problem be in the jar or bin files?

Link to comment
Share on other sites

I can only think on the basic stuff.

Did you set the PATH variable?

Also you should have reinstalled BlueJ after reinstalling the Java SDK, and thinking about it, is this the last version of BlueJ too?

 

 

Also you could import the toCharArray() method with:

import java.io.*;

Above the public class declaration....Although that not supposed to be required in standard BlueJ environment, it should work.

 

And try

import java.lang.*;

and tell me what happens, did you chose the correct Java SDK when installed BlueJ? (install BlueJ again)

Edited by reiniat
Link to comment
Share on other sites

I already tried importing both io and lang package but it didn't work. By PATH variable do you mean the one used to access javac in command prompt. I am using the latest version of bluej and java and I have tried reinstalling too in the same way as you suggested. Java SDK is also the right one and I even downloaded it again.

My thoughts dart to runtime because this appears during runtime.

Link to comment
Share on other sites

Still trying to solve the problem. I noticed something strange when I decided to use a string within the program instead as a parameters. This program is supposed to print initials of names but when I ran it using a string "Nico Belic" it gave output 124112 instead of N.B. and If I use any other name then also numbers are given out but when I ran a program to print vowels in the string then the output came right. The lang error occurs only when I try to use String as parameters even when executing the simplest of the program with a string which is to display the entered string itself.

 

Could this be a problem with the lang package or it goes deeper?

Here is the code for vowels program

 

public class pro

{

void disp()

{

String x="Nico Bellic";

int l=x.length();

char t;

int c=0;

for(int I=0;i<l;i++)

{

t=x.charAt(i);

if(t=='a' || t=='e' || t=='i' || t=='o' || t=='u')

{

c++;

}

}

System.out.println©;

}

}

Link to comment
Share on other sites

Could you post your entire code? Not just the class/function you are running? Not sure that it will make a difference, but I don't see anything wrong in that segment, so maybe there is some weird memory thing going on with the rest of it. I've seen weirder string output bugs result from a memory leak.

Prior to filing a bug against any of my code, please consider this response to common concerns.

Link to comment
Share on other sites

My f"""""""""""""""""""ing fault for putting single quotes instead of double in the print statement due to which it becomes a character which results in those numbers. So this weird output was my fault and it may be excluded from the problem. K^2,What do you suggest about the lang error ?Could it be a problem with bluej or java or my system?

Link to comment
Share on other sites

  • 2 months later...

I don't see a main method in the code you posted above. As K^2 said, can you please post your entire code here (or upload to PasteBin if it's large).

Also post the command line you used to compile it (e.g. javac initials.java). If you are compiling directly through BlueJ, try and find out what command line it's generating.

Link to comment
Share on other sites

Have you tried running the code on a different IDE? Try running it on Eclipse or a different IDE. Could be a possible error with the compiler. You could also try compiling your code online here. http://ideone.com/

Edited by Whiskey
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.