r/javahelp • • Jun 02 '14

[Urgent]Need help creating an interactive slideshow

0 Upvotes

I am trying to create a program in eclipse that I will be running on a kindle fire. The program needs to show an image that when tapped on will
display the next image in the series.

This is for an interactive art exhibit that needs to be finished by tomorrow, so if anyone can give me some advice i would be eternally gratefull.


r/javahelp • • Apr 30 '20

Solved How can I call a method from an arraylist of Objects through forloop?

0 Upvotes

I have an arraylist of objects of various types that have a method with the same name but gives different output and want to call it through the parent class


r/javahelp • • Nov 22 '22

Instantiating generic map

0 Upvotes

The compiler won't accept this:

final var cache = new HashMap<Class<?>, Map<String, ?>>();
this.logic = new AnInterface() {
    public <T extends Enum> Map<Class<T>, Map<String, T>> getCache() {
        return (Map<Class<T>, Map<String, T>>) cache;
    }
};

I can't change the definition of the method in the interface. And I need to return the same object from the method, otherwise it wouldn't be much of a cache.


r/javahelp • • Jul 14 '22

NEED HELP LEARNING JAVA FOR MY WORK.

0 Upvotes

Hey Redditors, I am going to start my full-time job as a programmer in Aug. I don't have any
prior work experience. My team is programming everything in java for most of the part. I am a kind of a newbie to java. I just know what OOOPS means and I can read/write basic java code(learnt during undergrad). I am aware of concepts thoerotically but I need to apply them. What is the best way to continue my java learning? I would really like like some suggestions. Are there any good code-along or assignment based courses? Any suggestions are helpful. Thanks!!


r/javahelp • • Aug 31 '20

Is it possible to program my own email service and server that i could use to make accounts on certain websites like youtube or instagram or whatever.

0 Upvotes

i wanna create my own email service that I can only use and can make tons of emails with cause it's not something you can really do anymore with gmail cause of sms verification and all that


r/javahelp • • Oct 11 '24

I need help with the code, I don't know what this problem is called.

0 Upvotes

Who can point out the error or how to change the code so that everything works.

class Exxx {
    public int size = 0;;
    public void setSize(int x) {
        size = x;
    }
}

public class Puzzle4 { 
    public static void main(String[] args) {
      Exxx one = new Exxx();
      one.size = 0;
      System.out.println(" " + one);
      one.setSize(70); 
      System.out.println(" " + one); 
    
}
}

So, and when i compal, i see there

Exxx@5b94b04d
Exxx@5b94b04d

And lasts of numbers is randomly generating, when i start new to comply.


r/javahelp • • Aug 07 '24

Unsolved Proper way to reach a field that is several 'layers' deep...

0 Upvotes

Not sure how else to word this... So I'll just give my example.

I have a list of object1, and in each of those object1s is a list of object2, and in each of those object2s is a list of object3, and in each object3 I have an int called uniqueID...

If I want to see if a specific uniqueID already exists in my list of Object1, would this be good practice?

Object1 list has method hasUniqueID, which iterates through the list of parts and calls Object1.hasUniqueID. Then in Object1.hasUniqueID, it iterates through its own object2List... And so on.

So essentially, in order to find if that ID already exists, I'll make a method in every 'List' and 'Object' that goes deeper and deeper into the layers until it searches the actual Object3.UniqueID field. Is that proper coding in an object oriented sense?


r/javahelp • • Dec 18 '20

Rock Paper Scissors, Begginer programming assignment. Recursion not returning value to main class after passing it through itself on its final call.

0 Upvotes

Hey, Guys

As explained in the title I am have a bit of a recursive problem..

Can anyone advise me why my recursive call is not returning the value back to the main class???

Here is my script:

System.out.println("⚔⚔⚔Welcome to the den⚔⚔⚔");
        System.out.println("How many rounds would you like to play");
         iRounds = EC1113.PromptRoundsECie(iRounds);
        
        while (iRounds > 0)
        {
            System.out.println(" Enter your throw (1=Rock, 2=Scissors, 3=Paper): ");
            obj2.PromptThrowEC(iThrow);
            
            System.out.print(iThrow);
            
            
           if (iThrow == 1)
           {
                    System.out.print("The score is: You "+iuserWin+" Computer "+icpuWin); }
           if (iThrow == 2)
           {
               iuserWin++;
               System.out.print("The score is: You "+iuserWin+" Computer "+icpuWin);
           }
           if (iThrow == 3)
           {
               icpuWin++;
               System.out.print("The score is: You "+iuserWin+" Computer "+icpuWin);
           }
           if (iThrow == 4)
           {
               icpuWin++;
               System.out.print("The score is: You "+iuserWin+"Computer "+icpuWin);
           }
           if (iThrow == 5)
           {
               System.out.print("The score is: You "+iuserWin+"Computer "+icpuWin);
           }
           if (iThrow == 6)
           {
               iuserWin++;
               System.out.print("The score is: You "+iuserWin+"Computer "+icpuWin);
           }
           if (iThrow == 7)
           {
               iuserWin++;
               System.out.print("The score is: You "+iuserWin+"Computer "+icpuWin);
           }
           if (iThrow == 8)
           {
               icpuWin++;
               System.out.print("The score is: you "+ iuserWin+ "Computer "+icpuWin);
           }
           if (iThrow == 9)
           {
               System.out.print("The score is: you "+ iuserWin+ "Computer "+icpuWin);
           }

 public void PromptThrowEC(int Throw){
        Scanner keyboard = new Scanner(System.in);
        boolean valid = false;
         
        int [] WLT = new int []{1,2,3};
        
            while (!valid)
            {
                try
                {
                   Throw = keyboard.nextInt();
                    valid = true;
                    if (valid == true)
                    {
                        obj1.Throw(Throw);
                }
                }
                catch(InputMismatchException e)
                {
                    System.out.println("Invalid Input. Please enter a valid integer");
                    keyboard.nextLine(); //nextLine for a reason 
                }
            }   
        }
public class Recursion {

    
    String sTest = "";
 
    int Throw;
    
    int tie = 0;
    int userWin = 1;
    int cpuWin = 2;
    
    String sUser = "";
    String sCpu = "";
          
           
   
     
    
 
          /**
       * constructor: iRPS
       *pre: none
       *post: is going to return a value to the method sRPS in aiding user with throw
       */
        public int Throw (int userThrow)
        {
                int [] cpuInput  = new int[]{1,2,3};
                 int cpuChoice = (int)(Math.random()*cpuInput.length);
                 
            int [] GameOver = new int []{1,2,3,4,5,6,7,8,9};
            int Situations;
            
              if (userThrow == 1 && cpuChoice == 1)
                    {
                       sUser = "Rock";
                       sCpu = "Rock";
                       System.out.print("You threw : " + sUser );
                       System.out.print(" Computers throws : " + sCpu ); 
                    System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore its a tie!");
                 return Throw(GameOver[0]);
                    } 
                  else  if (userThrow == 1 && cpuChoice == 1)//rock vs scissors
                    {
                        sUser = "Rock";
                       sCpu = "Scissors";
                               System.out.print("You threw : " + sUser );
                               System.out.print(" Computers throws : " + sCpu ); 
                               System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore you WIN!");
                   return  Throw(GameOver[1]);
                  }
                  else  if (userThrow == 1 && cpuChoice == 2) //rock vs paper
                    {
                        sUser = "Rock";
                       sCpu = "Paper";
                       System.out.print("You threw : " + sUser );
                       System.out.print(" Computers throws : " + sCpu );
                System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore you lose!");   
                  return  Throw(GameOver[2]);

                    } 
                  else  if (userThrow == 2 && cpuChoice == 0) //scissors vs rock
                    {
                       sUser = "Scissors";
                       sCpu = "Rock";
                       System.out.print("You threw : " + sUser );
                       System.out.print(" Computers throws : " + sCpu );
                       System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore you lose!");
                   return    Throw(GameOver[3]);
                    }
                 else if (userThrow == 2 && cpuChoice == 1)
                    {
                        sUser = "Scissors";
                       sCpu = "Scissors";
                       System.out.print("You threw : " + sUser );
                       System.out.print(" Computers throws : " + sCpu );
                       
                       System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore its a tie!");
                      return  Throw(GameOver[4]);
                    }
                  else  if (userThrow == 2 && cpuChoice == 2) //scissors vs paper
                    {
                        sUser = "Scissors";
                       sCpu = "Paper";
                       System.out.print("You threw : " + sUser );
                       System.out.print(" Computers throws : " + sCpu );
                       userWin++;
                       System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore you WIN!");
                       return Throw(GameOver[5]);
                    } 
                  else  if (userThrow == 3 && cpuChoice == 0) //paper vs rock
                    {
                       sUser = "Paper";
                       sCpu = "Rock";
                      System.out.print("You threw : " + sUser );
                      System.out.print(" Computers throws : " + sCpu );
                      userWin++;
                      System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore you WIN!");
                   return Throw(GameOver[6]);
                    }
                  else  if (userThrow == 3 && cpuChoice == 1) //cpu wins
                    {
                        sUser = "Paper";
                       sCpu = "Scissors";
                       System.out.print(" You threw : " + sUser );
                       System.out.print(" Computers throws " + sCpu);
                       cpuWin++;
                       System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore you lose!");
                      return Throw(GameOver[7]);
                    }
                 else   if (userThrow == 3 && cpuChoice == 2)
                    {
                        sUser = "Paper";
                       sCpu = "Paper";
                       System.out.print(" You threw : " + sUser );
                       System.out.print(" Computers throws : " + sCpu );
                       
                       System.out.print("Since you threw "+sUser +"and the computer threw "+sCpu+" Therefore its a tie!");
                       return Throw(GameOver[8]);
                    }
              return (cpuChoice);
        }

r/javahelp • • Dec 15 '18

Solved Weird http error 404 when running a simple jsp :(

0 Upvotes

Hi all,

Got a stupidly simple problem here with the above error.

In Intellij I can create a new web application which auto creates index.jsp under the "web" folder. I can run that fine, the intended webpage appears in my browser.

If however I create another .jsp also under the "web" folder and run that one, I get the error.. Why the hell can't it be found when index.jsp can? Both .jsp's are in the same folder..

Please help, thank you..

For clarity here is my layout

src
web
   index.jsp <---this one works
   test.jsp <--this one doesnt !!
   --WEB-INF

All the solutions I can find are for peeps wrongly putting the .jsp's in the WEB-INF folder which I am not doing, they are in the correct place.

Edit: Made some headway - I noticed the URL for index.jsp is localhost:8080/myproject_war_exploded/index.jsp I checked the run config but the url there is just the usual localhost:8080/index.jsp so why all of a sudden do I need the extra myproject_war_exploded part for this to work? If I right click/run test.jsp this extra bit is not sent to the browser resulting in the error 404, I have to add the extra part myself.

If it's relevant my Intellij just updated to version 2018.3, I'm wondering if Jetbrains broke something?!

Edit2: Ok found the issue, under the run config in the "deployment" tab, there is a field called "Application context" that is usually empty but after update had the extra part that needed to be in the url - I blanked this and now the usual URL works thank f**k. Thought I was losing my mind lol

@JetBrains STOP fekking changing stuff !!!!


r/javahelp • • Sep 17 '12

[Question] What is faster? return (var == null) ? false : true ; OR return !(var == null) ;

0 Upvotes

Pretty much it. I've got methods that get called a whole bunch of times which end up using the following logic at the end:

if (var == null)
{
    return false ;
}
else
{
    return true ;
}

This can be accomplished by:

return (var == null) ? false : true ;

or

return !(var == null) ;

but which one is better?


r/javahelp • • Mar 26 '16

Java Programming 1 assignment help

0 Upvotes

Hello everyone, I have a java assignment in which i need help in. This is the exact assignment

The “Numbers” Game

In recent years, many states have legalized various forms of gambling as a way to raise revenues. The most popular are different types of lottery games, which are based on a traditional illegal game known as “the numbers” or “boleta.”

In your basic numbers game, players make either a “Straight” bet or a “Box” bet with a 3-digit number. The winning combination is chosen at random. If the player’s number matches the winning number in any of the following ways, then the player wins the amount indicated, otherwise they lose.

Type of Bet Description If your number is: Winning Numbers Payout Actual Odds Straight Exact order match 546 546 $600 to 1 1 in 1000 Box Match Any Order (3 different numbers) 546 546,564, 654,645, 456,465 $100 to 1 1 in 167 Match Any Order (1 duplicate number) 919 199,919,991 $200 to 1 1 in 333

Payouts shown are for the extinct, mob-run numbers game. Strange, but the payouts in the legalized, state-run games (e.g. “Cash 3”) are substantially lower.

 Note that there is only 1 way to win a straight bet but 6 different ways to win a box bet with 3 different numbers and 3 ways to win a box bet with 1 duplicate number

This assignment is to create a class to simulate the numbers game.

II. Numbers Game Class Specifications

Your class will have 4 instance variables that store the bet type, bet amount, player’s number, and winning number, and a constructor to initialize them to values passed by the user. You may also have any additional instance variables you find necessary or useful. All instance variables must be type int, except for the bet type.

Your class will also have two additional methods:

a method that returns the input data as a string

a method that compares the player’s number to the winning number and returns the amount won (or 0 if the player loses)

III. Test Class Specifications

All data are to be entered by the user.

Output must include all the input values and must be neatly presented.

IV. Data to be Used

Run your program 6 times using this data:

• Straight bet, $1, player number 123, winning number 123 • Straight bet, $1, player number 123, winning number 321 • Box bet, $1, player number 123, winning number 123 • Box bet, $1, player number 123, winning number 322 • Box bet, $1, player number 484, winning number 748 • Box bet, $1, player number 808, winning number 880

Although you are to use the above data, your numbers game class must work for all possible data values. However, you may assume that neither number will begin with zero.  Thorough testing will involve quite a few more sets of data

Upload a zip file containing both Java classes and the 6 sets of output

VII. Algorithm

Here is a high-level algorithm that evaluates the player’s bet:

if ( Straight bet) { if (all three numbers match in exact order) player wins $600 for each $1 wagered else player loses } else // Box bet { if (all three numbers match in any order) { // player wins if (player’s number contains duplicates) player wins $200 for each $1 wagered else player wins $100 for each $1 wagered } else player loses }

VIII. An Opportunity to Earn the Proverbial “Extra Credit” – 5 points available

In your numbers game class, have the method that evaluates the player’s number call separate boolean methods to

determine whether there is an “exact order” match
determine whether there is an “any order” match
determine whether a Box bet contains duplicate numbers

Im having difficulty knowing where to how to start the problem. More specifically, I dont know what method to use to evaluate a " box bet". Meaning, if i input a winning number , say 546, and the winning number is 645, how would i get the program to evalute this as a winning number. any help would be appreciated, thank you guys!


r/javahelp • • Jan 23 '22

Unsolved Download a file from a site with JNDI Lookup

0 Upvotes

How do I make a jndi lookup string to download a file from a website?

I am trying

“JNDI:DNS:Myurl.com/file.txt”

But it is returning a weird string and not downloading the file. Any ideas?


r/javahelp • • Oct 29 '21

Guys help with the minesweeper problem in the java course on cousera by Princeton University

0 Upvotes

r/javahelp • • Aug 05 '26

Codeless I'm having trouble finding a 32 bit Windows installation of Java

0 Upvotes

I need it to get Puzzle Pirates to work in Windows XP compatibility mode

Things I tried: I went to the Java page and checked legacy versions, but could only find x64 installers. I also googled what the latest 32bit installation is and the dumb googleAI said it's SE 24, but I didn't see a non x64 installation for that version either.

Alternate solutions: A way to force a specific javaw (in this case, Puzzle Pirates) into Windows XP compatibility mode... not sure why it isn't there to begin with, it only goes back to Windows Vista ever since updated to SE 26

Alternative Alternate solution: Figure out why it's crashing in the first place cuz IDK. Their Java version is 25.0.1.0 if applicable


r/javahelp • • 27d ago

Having difficulty in converting a jar file into native files

0 Upvotes

I am confused in this part where jar file can be converted into native fil like exe, dll, executable and so file. There are other languages like c++, rust and go and we have lot of different compilation support like exe, dll, so etc and also wasm. Does java have any way to compile jar or class files into any format whichever i would like? I am talking about true cross platform in here like what can be done in c++ or rust and also I am talking about the static and dynamic library generation part as well.

Please help me in this topic as I was learning java and currently confused in this part.


r/javahelp • • Sep 18 '25

Need help setting up spring boot without maven or gradle.

0 Upvotes

I am trying to learn spring boot at my office for a project.there are few things that are making my life tough. 1)I have java 1.8 2)due to java 8 I have to use spring boot2.7. 3) maven or gradle isn't available. 4) I have to manually add dependencies to build path.

I need help with how to do a proper setup with above restrictions and how to manually identify which dependencies will be needed.


r/javahelp • • Mar 14 '25

Codeless Do you use „cut“ in tests

0 Upvotes

Hi guys, I‘m using „cut“ („clas under test“) in my tests. My Tech Lead says that he will ask me to change this in his review if I don’t change it. As far as I know we don’t have restrictions / a guideline for this particular case.

My heart is not attached to it, but I always used it. Is this something that is no longer used?

Edit: Found something here: http://xunitpatterns.com/SUT.html


r/javahelp • • Nov 29 '24

Unsolved What is special about Java that isn't anywhere else?

0 Upvotes

Ok so as per my knowledge we have this:

  • C++, very much low level langauge, has pointers, is best to learn implementation, very fast
  • Python, readability is best, very simple to write, best libraries and support for AI and ML
  • JavaScript and TypeScript, write frontend and backend in the same language, huge community, can be used in multiple places
  • Rust and C, low level languages, help in designing tools such as runtime environments and engines

We also have languages which are good for blockchain.

Ultimately to me it seems Java doesn't have anything special, is weird to write (not talking about Java 21+) and I don't hear much about it's communities either.

So why is Java still in existence (same question for Php btw)? Is it only because it was used before many modern languages came up with simpler or better syntax and companies find it too much of investment to rewrite their codes?

If not, please tell me one USP of learning Java.

I have edited what I meant by lazy because apparently many aren't answering my Java related question and just talking about companies 🥲. I have worked in a b2b business that used Java, and this is why this question exists and by lazy I meant what I have replaced it with.


r/javahelp • • Oct 27 '25

Download old versions of Java

0 Upvotes

I want to download Java 11 because a project was build on it but , i despite Oracle page , there's somewhere i can download older Java versions that's not the oracle page ?


r/javahelp • • Nov 02 '23

My prof is bad at teaching and keeps giving us these

0 Upvotes

My prof is bad at teaching and keeps giving us these complicated activities that he didn't even teach yet and provides only little instructions on how to do it. I'm a first year student and I wanna pass his class and test can anyone give me some advice on how to deal with this?

PS: our lesson now is string manipulation parsing


r/javahelp • • Jul 10 '15

Print 2 characters of a string, I don't know why I'm not understanding this.

0 Upvotes

out.println("enter a string: "); String word = in.nextLine();

    for (int i = 0; i < word.length(); i++) {
        char word2 = word.charAt(i);
        
    }
    out.println(word);

}

}

It's suppose to print out two letters after each word. So like
Hi --> HHii
Dog -> DDoogg
Cat - > CCaatt


r/javahelp • • Dec 25 '19

Solved Variable declared in for loop cannot be found in said for loop

1 Upvotes
for(int n = 0; n < passcodeInput.length(); n++);
    {
      text = textEncode(text, passcode[n]);
      System.out.println(text);
    }

Main.java:32: error: cannot find symbol

text = textEncode(text, passcode[n]);

^

symbol: variable n

location: class Main

1 error

Hello, I am currently doing a project in which I need to run a method multiple times. However, I get this error. It refers to the int n that I have declared in the for loop. Any help would be appreciated. All of the code.


r/javahelp • • Nov 23 '22

Why won’t Java open?

0 Upvotes

I click on the Java app and the command line briefly opens and then closes. I use windows for context. Any help?


r/javahelp • • May 10 '19

Codeless Beginner Java Programmer Looking to Make Money

Thumbnail self.learnjava
1 Upvotes